Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit 61eebb1

Browse files
committed
Add a short cut keybind, ctrl+s to save a memo
1 parent 173c03a commit 61eebb1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/Editor.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default {
5252
selectedIndex: 0
5353
}
5454
},
55+
// コンポーネントが作成されたタイミングで実行される
5556
created: function() {
5657
firebase
5758
.database()
@@ -63,6 +64,19 @@ export default {
6364
}
6465
})
6566
},
67+
// コンポーネントの描画が完了したタイミングで実行される
68+
mounted: function() {
69+
document.onkeydown = e => {
70+
if (e.key == 's' && e.metaKey) {
71+
this.saveMemos()
72+
return false
73+
}
74+
}
75+
},
76+
// コンポーネントが削除されるタイミングで実行される
77+
beforeDestroy: function() {
78+
document.onkeydown = null
79+
},
6680
methods: {
6781
logout: function() {
6882
firebase.auth().signOut()

0 commit comments

Comments
 (0)