aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-10-04 18:58:54 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-10-04 19:02:02 +0900
commit5e5fdafd94e8a3221224c0f7e17bda48a1de19cd (patch)
treeae742d25632a59dd10eacfce95facd71a1510736
parent3244c3c35db7639dc1bb08d9b0bcd40323e9d626 (diff)
fix key-repeat does not work
-rw-r--r--src/components/content-input.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/components/content-input.js b/src/components/content-input.js
index 6437128..10c785b 100644
--- a/src/components/content-input.js
+++ b/src/components/content-input.js
@@ -10,23 +10,26 @@ export default class ContentInputComponent {
}
onKeyPress(e) {
+ if (this.pressed[e.key] && this.pressed[e.key] !== 'keypress') {
+ return;
+ }
+ this.pressed[e.key] = 'keypress';
this.capture(e);
}
onKeyDown(e) {
+ if (this.pressed[e.key] && this.pressed[e.key] !== 'keydown') {
+ return;
+ }
+ this.pressed[e.key] = 'keydown';
this.capture(e);
}
onKeyUp(e) {
- this.pressed[e.key] = false;
+ delete this.pressed[e.key];
}
capture(e) {
- if (this.pressed[e.key]) {
- return;
- }
- this.pressed[e.key] = true;
-
if (e.target instanceof HTMLInputElement ||
e.target instanceof HTMLTextAreaElement ||
e.target instanceof HTMLSelectElement) {