Skip to content

Keybinding May 2026

handleKeydown(event: KeyboardEvent) const pressed = this.normalizeEvent(event); for (const binding of this.bindings.values()) const keys = binding.userKeys ?? binding.defaultKeys; if ( this.matches(pressed, keys) && (binding.context === "global"

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

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

return ( <table> bindings.map(b => ( <tr key=b.id> <td>b.label</td> <td> <kbd>b.userKeys?.join(" or ") ?? b.defaultKeys.join(" or ")</kbd> <button onClick=() => capture(b.id)> recording === b.id ? "Press keys..." : "Remap" </button> </td> </tr> )) </table> ); handleKeydown(event: KeyboardEvent) const pressed = this

✅ 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

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("+"); "Press keys

| Action | Default | Custom | |--------|---------|--------| | Save | Ctrl+S | (click to record) | | New File | Ctrl+N | Ctrl+Shift+N | | Find | Ctrl+F | F3 |

Share to...