gsplat-editor / editor /src /KeyboardManager.ts
dylanebert's picture
dylanebert HF staff
initial commit
e6b949c
raw
history blame contribute delete
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 };