summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/view/InputHandler.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/view/InputHandler.ts b/src/view/InputHandler.ts
index e39ffe0..dcfd85d 100644
--- a/src/view/InputHandler.ts
+++ b/src/view/InputHandler.ts
@@ -15,13 +15,17 @@ class InputHandler {
constructor() {
window.addEventListener('keydown', (ev) => {
- this.keys[ev.keyCode] = true;
- this.callListeners();
+ if (!this.keys[ev.keyCode]) {
+ this.keys[ev.keyCode] = true;
+ this.callListeners();
+ }
});
window.addEventListener('keyup', (ev) => {
- delete this.keys[ev.keyCode];
- this.callListeners();
+ if (this.keys[ev.keyCode]) {
+ delete this.keys[ev.keyCode];
+ this.callListeners();
+ }
});
}