From 520a9dff479933f40de75d336e6be2ad52b505d6 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 14 Nov 2023 05:55:55 -0800 Subject: [PATCH] Keyboard nav: 1/2/3 globally toggle table ordering. Esc closes search, slash also toggles search like Ctrl/Cmd+F does. --- frontend/src/App.vue | 11 ++++++++++- frontend/src/components/HeaderMain.vue | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f7daf92..f21bd91 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -51,6 +51,7 @@ const globalShortcutHandler = (event: KeyboardEvent) => { const fileExplorer = store.fileExplorer as any if (!fileExplorer) return const c = fileExplorer.isCursor() + const input = (event.target as HTMLElement).tagName === 'INPUT' const keyup = event.type === 'keyup' if (event.repeat) { if ( @@ -70,13 +71,21 @@ const globalShortcutHandler = (event: KeyboardEvent) => { else if (!keyup && event.key === 'f' && (event.ctrlKey || event.metaKey)) { headerMain.value!.toggleSearchInput() } + // Search also on / (UNIX style) + else if (keyup && !input && event.key === '/') { + headerMain.value!.toggleSearchInput() + } + // Globally close search on Escape + else if (keyup && event.key === 'Escape') { + headerMain.value!.closeSearch(event) + } // Select all (toggle); keydown to prevent builtin else if (!keyup && event.key === 'a' && (event.ctrlKey || event.metaKey)) { fileExplorer.toggleSelectAll() } // Keys 1-3 to sort columns else if ( - c && + !input && keyup && (event.key === '1' || event.key === '2' || event.key === '3') ) { diff --git a/frontend/src/components/HeaderMain.vue b/frontend/src/components/HeaderMain.vue index eefc739..5fab906 100644 --- a/frontend/src/components/HeaderMain.vue +++ b/frontend/src/components/HeaderMain.vue @@ -21,7 +21,6 @@ @input="updateSearch" placeholder="Search words" class="margin-input" - @keyup.escape="closeSearch" />