aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js65
1 files changed, 32 insertions, 33 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 9d3dc51b..ab0674a9 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -193,9 +193,8 @@ class Display {
onKeyDown(e) {
const key = Display.getKeyFromEvent(e);
- const handlers = Display.onKeyDownHandlers;
- if (hasOwn(handlers, key)) {
- const handler = handlers[key];
+ const handler = Display._onKeyDownHandlers.get(key);
+ if (typeof handler === 'function') {
if (handler(this, e)) {
e.preventDefault();
return true;
@@ -766,101 +765,101 @@ class Display {
}
}
-Display.onKeyDownHandlers = {
- 'Escape': (self) => {
+Display._onKeyDownHandlers = new Map([
+ ['Escape', (self) => {
self.onSearchClear();
return true;
- },
+ }],
- 'PageUp': (self, e) => {
+ ['PageUp', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(self.index - 3, null, true);
return true;
}
return false;
- },
+ }],
- 'PageDown': (self, e) => {
+ ['PageDown', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(self.index + 3, null, true);
return true;
}
return false;
- },
+ }],
- 'End': (self, e) => {
+ ['End', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(self.definitions.length - 1, null, true);
return true;
}
return false;
- },
+ }],
- 'Home': (self, e) => {
+ ['Home', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(0, null, true);
return true;
}
return false;
- },
+ }],
- 'ArrowUp': (self, e) => {
+ ['ArrowUp', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(self.index - 1, null, true);
return true;
}
return false;
- },
+ }],
- 'ArrowDown': (self, e) => {
+ ['ArrowDown', (self, e) => {
if (e.altKey) {
self.entryScrollIntoView(self.index + 1, null, true);
return true;
}
return false;
- },
+ }],
- 'B': (self, e) => {
+ ['B', (self, e) => {
if (e.altKey) {
self.sourceTermView();
return true;
}
return false;
- },
+ }],
- 'F': (self, e) => {
+ ['F', (self, e) => {
if (e.altKey) {
self.nextTermView();
return true;
}
return false;
- },
+ }],
- 'E': (self, e) => {
+ ['E', (self, e) => {
if (e.altKey) {
self.noteTryAdd('term-kanji');
return true;
}
return false;
- },
+ }],
- 'K': (self, e) => {
+ ['K', (self, e) => {
if (e.altKey) {
self.noteTryAdd('kanji');
return true;
}
return false;
- },
+ }],
- 'R': (self, e) => {
+ ['R', (self, e) => {
if (e.altKey) {
self.noteTryAdd('term-kana');
return true;
}
return false;
- },
+ }],
- 'P': (self, e) => {
+ ['P', (self, e) => {
if (e.altKey) {
const entry = self.getEntry(self.index);
if (entry !== null && entry.dataset.type === 'term') {
@@ -869,16 +868,16 @@ Display.onKeyDownHandlers = {
return true;
}
return false;
- },
+ }],
- 'V': (self, e) => {
+ ['V', (self, e) => {
if (e.altKey) {
self.noteTryView();
return true;
}
return false;
- }
-};
+ }]
+]);
Display._runtimeMessageHandlers = new Map([
['optionsUpdate', (self) => self.updateOptions(null)]