Skip to content

Record a shortcut from a + button, adding it beside the command's keys - #2952

Open
brhellman wants to merge 13 commits into
Foundry376:masterfrom
brhellman:shortcut-record-explicitly
Open

brhellman wants to merge 13 commits into
Foundry376:masterfrom
brhellman:shortcut-record-explicitly

Conversation

@brhellman

@brhellman brhellman commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Editing a shortcut on Preferences > Shortcuts is easy to get wrong. Measured on master (Gmail template, copy of a live config, Electron 44.5.1, DevTools input):

This PR:

  • A + button starts recording. The recorder shows "Press a shortcut, Esc to cancel" and takes focus, and every keymap is suspended until recording ends, so the keys reach nothing else (preventDefault keeps Tab from moving focus too).
  • Recording ends the way the keymap reads keys. A modifier combination ends it at once. A plain key waits SEQUENCE_TIMEOUT_MS (1000 ms, Mousetrap's _resetSequenceTimer) for a second one, so e alone works and g i is still a sequence.
  • It adds, never replaces. The command's current keys plus the new one go to keymap.json as a list (withBinding, which skips a key already there). Other commands' entries are kept.
  • Esc cancels, and so does clicking elsewhere (blur, leaving focus where it went). Unmounting mid-recording gives the keyboard back. After a save or Esc, focus returns to the + button, inside Preferences.
  • The keymap read/write and the key-to-binding rules move to user-keymap.ts. The never-firing onKeyPress handler is gone: preventDefault on keydown cancels keypress. The page's two instructions now describe +, and their old strings are removed from each language file.

Removing keys (an × per key, Clear per section, Clear all) is the follow-up. It needs #2950 for [] to mean "no keys".

Verified: shortcut-recording-spec covers the helpers (sequence vs modifier syntax, mod on each platform, no duplicate key, a missing keymap read silently and a broken one logged). It also mounts CommandItem against a temporary keymap.json: no recorder before +, focus and suspension on +, a single key saved after the timeout alongside e with other commands kept, g i saved once, Ctrl+K saved at once as mod+k, Esc and blur saving nothing, preventDefault on recorded keys, and the keyboard resumed on unmount. Every statement and condition added was mutated: 24 of 24 red. Live, in this branch's build (same setup as above, thread focused, queueTask stubbed): + showed the prompt with focus in the recorder. Pressing s, Gmail's star key, queued nothing, and 1.2 s later Archive read E, S with ["e", "s"] saved and focus on +. A second + then Esc saved nothing and left Preferences open. Lint, prettier and tsc clean; full suite 2452 passing on this branch (master 4ebb582fb).

Shortcuts page series (one concern each; merge in this order): #2950 [] unbinds, #2951 mail held behind Preferences, #2952 record with +, #2953 remove keys, #2955 conflict warnings, #2956 visual pass, #2957 search, #2958 single-key switch, #2959 Show filter.

🤖 Generated with Claude Code

Recording began whenever a row took focus and ended on its own, a single plain key could not be
recorded (the row waited for a second one and saved "k then j"), and the result replaced every
key the command had. Recording now starts from a + button and says so; a modifier combination
ends it at once, a plain key after Mousetrap's one-second sequence timeout; Esc cancels; the
key joins the command's existing ones; focus returns to the button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brhellman

Copy link
Copy Markdown
Contributor Author

@bengotow, a direction question on the Shortcuts page series (#2952–#2959). It's been open five weeks, so rather than keep rebasing it I'd like to know what shape you want it in.

As of today all seven are rebased onto master 9a066af and mergeable, and each one passes lint, typecheck and the full suite. Together they change about 1,850 lines outside app/lang. Every PR stays inside Preferences except #2955 (keymap-manager.ts) and #2958 (keymap-manager.ts, menu-manager.ts, config-schema.ts).

Options, whichever is easiest for you to review:

  1. As is, in order. Seven PRs of roughly 100–500 lines each, one concern apiece, merged bottom-up from Record a shortcut from a + button, adding it beside the command's keys #2952.
  2. Three PRs. (a) Editing: record from +, remove, conflict warnings (Record a shortcut from a + button, adding it beside the command's keys #2952, Remove shortcuts from the Shortcuts page: a key at a time, a section, or all #2953, Warn when a shortcut you added also runs another command #2955). (b) Finding and reading: visual pass, search, Show filter (Make the Shortcuts page easier to read: keycaps, + Add, a changed marker #2956, Search the Shortcuts page by command name or key, or by pressing a key #2957, Show only changed or conflicting shortcuts, from a Show menu or the conflict count #2959). (c) The WCAG 2.1.4 single-key switch (Let single-key shortcuts be turned off, as WCAG 2.1.4 asks #2958) on its own, since it's the one that changes key handling outside Preferences.
  3. Only part of it. Say which pieces you want, e.g. just Let single-key shortcuts be turned off, as WCAG 2.1.4 asks #2958 and Warn when a shortcut you added also runs another command #2955, and I'll close the rest and rebase what's left directly onto master.
  4. Not now. Close the series and I'll stop carrying it.

Any of these is fine. I'd just rather have a direction than keep it parked.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant