diff options
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/search.js | 28 | ||||
-rw-r--r-- | ext/bg/search.html | 1 |
2 files changed, 15 insertions, 14 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 00148418..5963c03b 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -44,7 +44,7 @@ class DisplaySearch extends Display { }); this.autoPlayAudioDelay = 0; - this.registerActions([ + this.hotkeyHandler.registerActions([ ['focusSearchBox', this._onActionFocusSearchBox.bind(this)] ]); } @@ -73,6 +73,7 @@ class DisplaySearch extends Display { window.addEventListener('copy', this._onCopy.bind(this)); this._clipboardMonitor.on('change', this._onExternalSearchUpdate.bind(this)); this._clipboardMonitorEnableCheckbox.addEventListener('change', this._onClipboardMonitorEnableChange.bind(this)); + this.hotkeyHandler.on('keydownNonHotkey', this._onKeyDown.bind(this)); this._onModeChange(); @@ -81,19 +82,6 @@ class DisplaySearch extends Display { this._isPrepared = true; } - onKeyDown(e) { - if ( - !super.onKeyDown(e) && - document.activeElement !== this._queryInput && - !e.ctrlKey && - !e.metaKey && - !e.altKey && - e.key.length === 1 - ) { - this._queryInput.focus({preventScroll: true}); - } - } - postProcessQuery(query) { if (this._wanakanaEnabled) { try { @@ -115,6 +103,18 @@ class DisplaySearch extends Display { // Private + _onKeyDown(e) { + if ( + document.activeElement !== this._queryInput && + !e.ctrlKey && + !e.metaKey && + !e.altKey && + e.key.length === 1 + ) { + this._queryInput.focus({preventScroll: true}); + } + } + async _onOptionsUpdated() { await this.updateOptions(); const query = this._queryInput.value; diff --git a/ext/bg/search.html b/ext/bg/search.html index 43f9f7eb..dae657e8 100644 --- a/ext/bg/search.html +++ b/ext/bg/search.html @@ -92,6 +92,7 @@ <script src="/mixed/js/display-history.js"></script> <script src="/mixed/js/display-notification.js"></script> <script src="/mixed/js/dynamic-loader.js"></script> +<script src="/mixed/js/hotkey-handler.js"></script> <script src="/mixed/js/media-loader.js"></script> <script src="/mixed/js/scroll.js"></script> <script src="/mixed/js/text-scanner.js"></script> |