From 14b4aee07dc3f69ad75518cf04cafe416e06f0c7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 17 Jan 2021 16:55:45 -0500 Subject: Hotkey forwarding support (#1263) * Add support for allowing HotkeyHandler to forward hotkeys * Update hotkey registration * Pass HotkeyHandler instance into Display* constructor * Implement hotkey forwarding --- ext/bg/js/search-main.js | 7 ++++++- ext/bg/js/search.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/search-main.js b/ext/bg/js/search-main.js index 73bc6750..38c6f4dd 100644 --- a/ext/bg/js/search-main.js +++ b/ext/bg/js/search-main.js @@ -18,6 +18,7 @@ /* global * DisplaySearch * DocumentFocusController + * HotkeyHandler * JapaneseUtil * api * wanakana @@ -32,7 +33,11 @@ await yomichan.backendReady(); const japaneseUtil = new JapaneseUtil(wanakana); - const displaySearch = new DisplaySearch(japaneseUtil, documentFocusController); + + const hotkeyHandler = new HotkeyHandler(); + hotkeyHandler.prepare(); + + const displaySearch = new DisplaySearch(japaneseUtil, documentFocusController, hotkeyHandler); await displaySearch.prepare(); document.documentElement.dataset.loaded = 'true'; diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 5963c03b..e2497264 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -23,8 +23,8 @@ */ class DisplaySearch extends Display { - constructor(japaneseUtil, documentFocusController) { - super('search', japaneseUtil, documentFocusController); + constructor(japaneseUtil, documentFocusController, hotkeyHandler) { + super('search', japaneseUtil, documentFocusController, hotkeyHandler); this._searchButton = document.querySelector('#search-button'); this._queryInput = document.querySelector('#search-textbox'); this._introElement = document.querySelector('#intro'); -- cgit v1.2.3