Skip to content

Let single-key shortcuts be turned off, as WCAG 2.1.4 asks - #2958

Open
brhellman wants to merge 93 commits into
Foundry376:masterfrom
brhellman:shortcut-single-key-switch
Open

brhellman wants to merge 93 commits into
Foundry376:masterfrom
brhellman:shortcut-single-key-switch

Conversation

@brhellman

@brhellman brhellman commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Gmail-style shortcuts are single characters: e archives, # deletes, s stars. WCAG 2.1.4 Character Key Shortcuts (level A) requires that such shortcuts can be turned off or remapped, and its own example is an email client where a speech-input user dictating "e" archives a message. Gmail has a "Keyboard shortcuts off" setting for the same reason. Mailspring's only way out is changing the template or clearing keys one by one, which loses your setup.

  • core.keymapSingleKeys (default on), shown on the Shortcuts page as "Single-key shortcuts, like E to archive" with a line explaining when to turn it off.
  • What counts: isCharacterKeyShortcut is a binding whose every keystroke is a character typed with at most Shift: e, shift+3, #, g i, space. Shortcuts with Ctrl, Alt or Cmd, and non-character keys like Enter, Escape, the arrows and F-keys, are untouched, as WCAG 2.1.4 exempts them.
  • Where it applies: KeymapManager keeps the configured keys (getBindingsForCommand, which the Shortcuts page edits) and builds a separate active set, getActiveBindingsForAllCommands. Key handling (_commandsCache) and the menu accelerators (MenuManager.update) use the active set, so a turned-off E neither runs Archive nor shows as its accelerator. A change to the setting takes effect at once, through onDidChange.
  • On the page: turned-off keys stay listed, struck through and titled "Off: single-key shortcuts are turned off", so turning the switch back on restores exactly what you had.

Stacked on #2957.

Verified: keymap-manager-spec covers what counts as a character key and what doesn't, a plain key running while on (pressed as a keypress, which is how Mousetrap binds plain keys), the active set dropping e but keeping mod+n while off, nothing running on e while off, the change taking effect without a reload, and the menu receiving the active set. The Shortcuts specs cover the switch reflecting and setting the config, and only single keys showing as off. Every statement and condition added was mutated: 19 of 19 red. That included a vacuous first version of the dispatch spec, which pressed e as a keydown that never reached Mousetrap. Live, in this branch's build on a copy of a Gmail-template config (Electron 44.5.1, DevTools input, queueTask stubbed): with a thread focused, e queued an archive; clicking the switch saved false and struck through Archive's E; then e queued nothing while mod+n stayed active. Lint, prettier and tsc clean; full suite 2506 passing.

Screenshot: the switch off, with single keys struck through and Ctrl/Alt/Cmd shortcuts untouched:

single keys off

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

Brian Hellman and others added 8 commits October 7, 2026 20:59
KeymapFile created a command's entry only while pushing its first keystroke, so `[]` left no
entry and the template's keys stayed bound: there was no way to remove a shortcut, even by
editing the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
… or all

Each key is a chip with an x that removes it (and any other spelling of the same key), a
command the user keymap changed gets a Reset back to the template, each section has a Clear,
and Clear All (confirmed) empties every command. A command left with no keys is written as
`[]`, which unbinds it. "None" is localized now that it shows on cleared commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every command bound to a key runs when it is pressed, so adding "s" to Archive while Star has
"s" made one key archive and star. The Shortcuts page now marks both keys, says on the row the
key was added to which other command it runs, offers to remove it from either, and counts these
at the top. The defaults' own shared keys (Outlook's Ctrl+U underlines in the composer and marks
unread in the list) are not flagged: KeymapManager keeps each command's keys from before the
user keymap so a key the user added can be told from one the template gave.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keys are drawn as keycaps at the small text size rather than run together in a monospace line,
the add button says "+ Add", a dot marks a command changed from the default, rows highlight on
hover with their x buttons, and the sections flow into one column in a narrow window and two in
a wide one instead of a fixed 800px split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A search box above the list narrows it to commands whose name matches or that have a matching
key as written (ctrl+r, and cmd/control/option for the modifier names), hiding empty sections.
Find by key listens for one shortcut and lists the commands it runs, or says nothing does.
Section Clear links hide while searching so they never clear rows out of sight. The key
recorder and key formatting move out of the row into ShortcutRecorder and keystrokes.tsx so the
row and the search share them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A switch on the Shortcuts page, core.keymapSingleKeys, stops every shortcut typed without Ctrl,
Alt or Cmd ("e", "shift+3", "g i") from running a command or appearing as a menu accelerator,
while leaving them in the list, struck through, to come back when it is turned on. Someone
dictating the letter "e" would otherwise archive a message; others turn them off to avoid
typing into the wrong place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brian Hellman added 30 commits November 9, 2026 12:01
…licitly

# Conflicts:
#	app/lang/en.json
#	app/lang/hu.json
#	app/lang/pt.json
# Conflicts:
#	app/lang/en.json
#	app/lang/hu.json
#	app/lang/pt.json
# Conflicts:
#	app/src/menu-manager.ts

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