diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-06-24 16:58:58 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-06-24 16:58:58 +1000 |
| commit | 343ee5d2fc2c98a5a2f1a431a96769119080b959 (patch) | |
| tree | 574a217a31b999e06c85370859a518874fe2b716 | |
| parent | f8fb0af9aaacf96bb82fab006cc4bf32565fd61c (diff) | |
Use Ctrl-f to open search bar, and Ctrl-Shift-f to switch search-mode
| -rw-r--r-- | src/App.vue | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/App.vue b/src/App.vue index 5505b8b..22b1df3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -760,11 +760,21 @@ export default defineComponent({ onKeyUp(evt: KeyboardEvent){ if (evt.key == 'Escape'){ this.resetMode(); - } else if (evt.key == 'F' && evt.ctrlKey){ // On ctrl-shift-f - if (!this.searchOpen){ - this.onSearchIconClick(); - } else { - (this.$refs.searchModal as InstanceType<typeof SearchModal>).focusInput(); + } else if (evt.key == 'f' && evt.ctrlKey){ + // If no non-search modal is open, open/focus search bar + if (this.infoModalNodeName == null && !this.helpOpen && !this.settingsOpen){ + evt.preventDefault(); + if (!this.searchOpen){ + this.onSearchIconClick(); + } else { + (this.$refs.searchModal as InstanceType<typeof SearchModal>).focusInput(); + } + } + } else if (evt.key == 'F' && evt.ctrlKey){ + // If search bar is open, swap search mode + if (this.searchOpen){ + this.uiOpts.jumpToSearchedNode = !this.uiOpts.jumpToSearchedNode; + this.onSettingsChg([], ['jumpToSearchedNode']); } } }, @@ -886,12 +896,12 @@ export default defineComponent({ }, created(){ window.addEventListener('resize', this.onResize); - window.addEventListener('keyup', this.onKeyUp); + window.addEventListener('keydown', this.onKeyUp); this.initTreeFromServer(); }, unmounted(){ window.removeEventListener('resize', this.onResize); - window.removeEventListener('keyup', this.onKeyUp); + window.removeEventListener('keydown', this.onKeyUp); }, components: { Tile, AncestryBar, |
