Spaces:
Running
Running
Download editor/src/KeyboardManager.ts from dylanebert/gsplat-editor: direct link, hf CLI and curl.
- Browser
- Download file 613 Bytes
-
https://huggingface.co/spaces/dylanebert/gsplat-editor/resolve/main/editor/src/KeyboardManager.ts
- Command line
-
hf download hf://spaces/dylanebert/gsplat-editor/editor/src/KeyboardManager.ts
-
curl -L -o KeyboardManager.ts https://huggingface.co/spaces/dylanebert/gsplat-editor/resolve/main/editor/src/KeyboardManager.ts
613 Bytes
| import { InputHandler } from "./InputHandler"; | |
| class KeyboardManager implements InputHandler { | |
| private _keyMap: Map<string, (event: KeyboardEvent) => void>; | |
| constructor() { | |
| this._keyMap = new Map(); | |
| } | |
| registerKey(key: string, callback: (event: KeyboardEvent) => void) { | |
| this._keyMap.set(key, callback); | |
| } | |
| unregisterKey(key: string) { | |
| this._keyMap.delete(key); | |
| } | |
| handleInput(event: KeyboardEvent) { | |
| const callback = this._keyMap.get(event.key); | |
| if (callback) { | |
| callback(event); | |
| } | |
| } | |
| } | |
| export { KeyboardManager }; | |