feat(hotkeys): end-user keymap customization#48
Merged
Conversation
The second v1.14-deferred accelerator. Lets a USER (not just the developer)
remap shortcuts and have the choice persist (research-10) — pure composition
over the record defaults, NO change to the closed CommandRecord. The
reproducible zero-dependency equivalent already shipped as
docs/hand-written-keymap-override.md (v1.14); this is the tested package layer.
- bindHotkeys(registry, { keymap }) — an optional UserKeymap (sparse
commandId → { replace | add | remove }) layered over each record's default
keybinding at bind time. Default empty → existing callers unaffected.
useHotkeys (React) forwards it and re-binds on keymap identity change (live
remap UI).
- Pure keymap.ts: resolveKeys (override resolution); collectBindings gained a
keymap param and orders user-touched bindings first on a shared key; and
detectConflicts (definite/possible same-key clashes).
- Capture/display primitives: tokenFromEvent (press-to-record), isReservedCombo
/ RESERVED_COMBOS, formatKeybinding, layoutLabel (getLayoutMap w/ fallback).
- keymap.ts is tinykeys-free; bind.ts composes it (two-layer discipline).
- +14 tests (23 in the package; the 9 pre-existing bind tests still pass →
backward-compatible). minor changeset (1.0.1 → 1.1.0).
Left to the app (primitives cover it): the full remap-UI React component,
preset packs, cloud sync, the WCAG "disable character-key shortcuts" toggle.
Claude-Session: https://claude.ai/code/session_016teVFousRsWNhiiPNpG1p9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The second v1.14-deferred accelerator. Lets a user (not just the developer) remap shortcuts and have the choice persist (research-10) — pure composition over the record defaults, no change to the closed
CommandRecord. The zero-dependency reproducible equivalent already shipped asdocs/hand-written-keymap-override.md(v1.14); this is the testedacture-hotkeyspackage layer.Almost no SaaS ships user-remapping (Figma/Linear/Slack don't) — and no JS hotkey library ships a persisted rebindable keymap with conflict detection — so this is a genuine differentiator, not a reinvention.
Changes
bindHotkeys(registry, { keymap })— an optionalUserKeymap(sparsecommandId → { replace | add | remove }) layered over each record's defaultkeybindingat bind time. Default empty → existing callers unaffected.useHotkeys(React) forwards it and re-binds on keymap identity change, so a live remap UI takes effect.keymap.ts:resolveKeys(override resolution);collectBindingsgained akeymapparam and orders user-touched bindings first on a shared key (VS Code's "user override wins, scope respected");detectConflicts(registry, keymap?)(definite/possibleclashes).tokenFromEvent(press-to-record),isReservedCombo/RESERVED_COMBOS,formatKeybinding(⌘/Ctrl),layoutLabel(getLayoutMap, with fallback).keymap.tsis tinykeys-free;bind.tscomposes it.minorchangeset (acture-hotkeys1.0.1 → 1.1.0).Left to the app (the primitives cover it)
The full remap-UI React component, preset packs, cloud sync, and the WCAG 2.1.4 "disable character-key shortcuts" toggle — documented, YAGNI-gated.
https://claude.ai/code/session_016teVFousRsWNhiiPNpG1p9