summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 11:39:36 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-07 11:39:36 +0100
commitc9d51face0c5cbca38dc9c27379454405a57ade0 (patch)
tree83f7998deca4c31e5c1b9687c3bcc18b9fba040a /src
parent584728a1293a5215baaca4e7de813b2a85b8253d (diff)
downloadrpgedit-c9d51face0c5cbca38dc9c27379454405a57ade0.tar
rpgedit-c9d51face0c5cbca38dc9c27379454405a57ade0.zip
view/InputHandler: don't call listeners when no key state has changed
Diffstat (limited to 'src')
-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();
+ }
});
}