Skip to main content

Keybinding

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

private normalizeKeyString(keys: string): string return keys.toLowerCase().replace(/\s/g, ""); keybinding

private matches(pressed: string, bindingKeys: string[]): boolean return bindingKeys.some(k => this.normalizeKeyString(k) === pressed); on(id: string, callback: () => void) if (

✅ Manager class with registration, remapping, context support ✅ React hook + provider integration ✅ UI panel for user customization ✅ Conflict detection (optional but recommended) ✅ Local storage persistence ✅ Keyboard normalization & matching callback: () =&gt

private normalizeEvent(e: KeyboardEvent): string const parts = []; if (e.ctrlKey) parts.push("ctrl"); if (e.shiftKey) parts.push("shift"); if (e.altKey) parts.push("alt"); if (e.metaKey) parts.push("meta"); parts.push(e.key.toLowerCase()); return parts.join("+");

private trigger(id: string) const callbacks = this.listeners.get(id); callbacks?.forEach(cb => cb());

setContext(context: string) this.activeContext = context;