summaryrefslogtreecommitdiff
path: root/ext/bg/js/search.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-10 13:40:48 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-10 13:40:48 -0500
commit157e6f7c75a20453e17668c0e8886f46b7f4b7ac (patch)
tree505085d34521d7bf53565b5d90d87feeb43e5156 /ext/bg/js/search.js
parent120f97be2601fcf47294d9f4ab1f7c06f7bc6c05 (diff)
Optimize DisplaySearch.onKeyDown
Diffstat (limited to 'ext/bg/js/search.js')
-rw-r--r--ext/bg/js/search.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 290830f4..ad579918 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -179,27 +179,14 @@ class DisplaySearch extends Display {
onKeyDown(e) {
const key = Display.getKeyFromEvent(e);
+ const ignoreKeys = DisplaySearch.onKeyDownIgnoreKeys;
- let activeModifierMap = {
+ const activeModifierMap = {
'Control': e.ctrlKey,
'Meta': e.metaKey,
'ANY_MOD': true
};
- const ignoreKeys = {
- 'ANY_MOD': ['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End']
- .concat(
- Array.from(Array(24).keys())
- .map(i => `F${i + 1}`)
- ),
- 'Control': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'],
- 'Meta': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'],
- 'OS': [],
- 'Alt': [],
- 'AltGraph': [],
- 'Shift': []
- }
-
let preventFocus = false;
for (const [modifier, keys] of Object.entries(ignoreKeys)) {
const modifierActive = activeModifierMap[modifier];
@@ -364,4 +351,19 @@ DisplaySearch.runtimeMessageHandlers = {
}
};
+DisplaySearch.onKeyDownIgnoreKeys = {
+ 'ANY_MOD': [
+ 'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End',
+ 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10',
+ 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F20',
+ 'F21', 'F22', 'F23', 'F24'
+ ],
+ 'Control': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'],
+ 'Meta': ['C', 'A', 'Z', 'Y', 'X', 'F', 'G'],
+ 'OS': [],
+ 'Alt': [],
+ 'AltGraph': [],
+ 'Shift': []
+};
+
window.yomichan_search = DisplaySearch.create();