From: Adam Dullage Date: Thu, 17 Feb 2022 13:16:37 +0000 (+0000) Subject: 'e' to Edit Shortcut X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=24cf3fa1d2b903082be32544a04a33c6a80d80e0;p=flatnotes.git 'e' to Edit Shortcut --- diff --git a/README.md b/README.md index 2c1d359..29fb72f 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ This is what flatnotes aims to achieve. * [x] Ability to Create a Note * [x] Ability to Rename a Note * [x] Routing +* [x] e to edit * [ ] Loading & Not Found Indicators * [ ] Ability to Delete a Note * [ ] / to search -* [ ] e to edit * [ ] CTRL-S to save * [ ] Drafts * [ ] Image Embedding diff --git a/flatnotes/src/components/App.js b/flatnotes/src/components/App.js index 393c7e1..675517a 100644 --- a/flatnotes/src/components/App.js +++ b/flatnotes/src/components/App.js @@ -228,10 +228,34 @@ export default { history.replaceState(null, "", this.currentNote.href); this.toggleEditMode(); }, + + keyboardShortcuts: function(e) { + // 'e' to Edit + if ( + e.key == "e" && + this.currentView == this.views.note && + this.editMode == false + ) { + e.preventDefault(); + this.toggleEditMode(); + } + + // 'CTRL + s' to Save + // else if ( + // e.key == "s" && + // e.ctrlKey == true && + // this.currentView == this.views.note && + // this.editMode == true + // ) { + // e.preventDefault(); + // this.saveNote(); + // } + }, }, created: function() { EventBus.$on("logout", this.logout); + document.addEventListener("keydown", this.keyboardShortcuts); let token = localStorage.getItem("token"); if (token != null) {