summaryrefslogtreecommitdiffstats
path: root/src/view
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 12:18:40 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-01-08 12:18:40 +0100
commit4de2a6636a4de682edc5c3bbd4d1f5e940e879a3 (patch)
tree6646abcc839215427b5cf6a145d8570cc57652d6 /src/view
parent9f74746b2ebffbfe40f359171be2698532ef0810 (diff)
downloadrpgedit-4de2a6636a4de682edc5c3bbd4d1f5e940e879a3.tar
rpgedit-4de2a6636a4de682edc5c3bbd4d1f5e940e879a3.zip
InputHandler: prevent default for relavant keys
Diffstat (limited to 'src/view')
-rw-r--r--src/view/InputHandler.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/view/InputHandler.ts b/src/view/InputHandler.ts
index 86d4ec6..d06bcf8 100644
--- a/src/view/InputHandler.ts
+++ b/src/view/InputHandler.ts
@@ -13,8 +13,13 @@ class InputHandler {
this.listeners.forEach(l => l());
}
- constructor() {
+ constructor(private relevantKeys: {[key: number]: boolean}) {
window.addEventListener('keydown', (ev) => {
+ if (!relevantKeys[ev.keyCode])
+ return;
+
+ ev.preventDefault();
+
if (!this.keys[ev.keyCode]) {
this.keys[ev.keyCode] = true;
this.callListeners();
@@ -22,6 +27,11 @@ class InputHandler {
});
window.addEventListener('keyup', (ev) => {
+ if (!relevantKeys[ev.keyCode])
+ return;
+
+ ev.preventDefault();
+
if (this.keys[ev.keyCode]) {
delete this.keys[ev.keyCode];
this.callListeners();