Keybinding Access

function KeybindingSettings( bindings, onRemap ) null>(null); const capture = (id: string) => setRecording(id); const handler = (e: KeyboardEvent) => e.preventDefault(); const keys = normalizeEvent(e); onRemap(id, [keys]); setRecording(null); window.removeEventListener("keydown", handler); ; window.addEventListener("keydown", handler); ;

function Editor() useKeybinding("save", () => console.log("Saved via Ctrl+S"); ); return <textarea />; keybinding

private matches(pressed: string, bindingKeys: string[]): boolean return bindingKeys.some(k => this.normalizeKeyString(k) === pressed); function KeybindingSettings( bindings

on(id: string, callback: () => void) if (!this.listeners.has(id)) this.listeners.set(id, new Set()); this.listeners.get(id)!.add(callback); onRemap ) null&gt

function useKeybinding(id: string, callback: () => void, deps: any[] = []) const manager = useKeybindingManager(); // from context useEffect(() => manager.on(id, callback); return () => manager.off(id, callback); , [id, callback, ...deps]);