summaryrefslogtreecommitdiffstats
path: root/src/view/input/inputhandler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/input/inputhandler.ts')
-rw-r--r--src/view/input/inputhandler.ts44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/view/input/inputhandler.ts b/src/view/input/inputhandler.ts
deleted file mode 100644
index 17abfe6..0000000
--- a/src/view/input/inputhandler.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Listenable } from '../../util';
-
-export class InputHandler extends Listenable<[string, boolean]> {
- private readonly keys: Set<string> = new Set();
-
- constructor(relevantKeys: Set<string>) {
- super();
-
- window.addEventListener('keydown', (ev) => {
- if (!relevantKeys.has(ev.code))
- return;
-
- ev.preventDefault();
-
- if (ev.repeat)
- return;
-
- this.keys.add(ev.code);
- this.runListeners(ev.code, true);
- });
-
- window.addEventListener('keyup', (ev) => {
- if (!relevantKeys.has(ev.code))
- return;
-
- ev.preventDefault();
-
- if (!this.keys.has(ev.code))
- return;
-
- this.keys.delete(ev.code);
- this.runListeners(ev.code, false);
- });
-
- window.addEventListener('blur', () => {
- this.keys.clear();
- this.runListeners('', false);
- });
- }
-
- public has(key: string): boolean {
- return this.keys.has(key);
- }
-}