Repository navigation
Description
Description
In Preferences → Key Bindings, recording a shortcut that combines Shift with a digit or punctuation key silently loses the Shift modifier: pressing ⌘⇧7 shows — and saves — Cmd+7. The stored binding differs from what the user physically pressed, with no feedback. Letter keys are unaffected (⌘⇧B records Cmd+Shift+B correctly).
Root cause (code-level)
The key-input dialog (prefComponents/keybindings/key-input-dialog.vue) delegates recording to getAcceleratorFromKeyboardEvent from @hfelix/[email protected]. Its atom-keymap port only keeps shift as a modifier when the key is a non-character key (F-keys, arrows, …) or an uppercase Latin letter:
// @hfelix/electron-localshortcut src/atom-keymap/helpers.js
if (key === 'shift' || (shiftKey && (isNonCharacterKey || (isLatinCharacter(key) && isUpperCaseCharacter(key))))) {
keyInputEvent.shift = true
}This follows Atom's keystroke philosophy: for shifted digits/punctuation, the shifted character is supposed to be recorded instead (Shift+7 → & on a US layout). But on macOS with ⌘ held, KeyboardEvent.key reports the base character (7), so neither the Shift modifier nor the shifted character survives — the recorded accelerator collapses to plain Cmd+7.
Steps to Reproduce
- Open Preferences → Key Bindings.
- Rebind any command (e.g. Bold) and press ⌘⇧7.
- The dialog shows
Cmd+7; saving registersCmd+7. - Afterwards ⌘7 triggers the command and ⌘⇧7 does not.
Expected Behavior
Either record CmdOrCtrl+Shift+7 (a combination Electron accelerators support — the menu would render it as ⇧⌘7), or visibly reject the keystroke — anything but silently saving a different combination than the one pressed.
Actual Behavior
Cmd+7 is saved without any indication that Shift was dropped.
Operating System
Found on macOS (develop, 0.20.0-dev). The shift-recording rule itself is platform-independent, but the exact outcome may vary per OS/layout because it depends on what KeyboardEvent.key reports under a held primary modifier.
Notes
- Found while hand-verifying fix: sync the inline format toolbar with custom keybindings #4862 (the [Bug] muya inline format toolbar shortcut hints don't follow custom keybindings #4687 fix); this bug is unrelated to that change and reproduces on
develop. - A possible marktext-side fix that avoids touching the library: post-process the recorded accelerator in the key-input dialog — when
event.shiftKeywas held, the accelerator contains noShift, and the recorded key equals the layout's unshifted base character forevent.code(the native-keymap layout info is already available to the configurator), appendShift. I'm happy to attempt this as a PR if that direction sounds right — or an upstream fix in@hfelix/electron-localshortcut, whichever you prefer.
Reproducibility
- I can reliably reproduce this issue
Activity
fix(desktop): preserve Shift for Cmd/Ctrl+digit keybindings (#4863)
ci: apply dependency patches before unit tests
fix: cherry-pick seven upstream fixes; cure state-clone aliasing
Jocs commentedon Sep 22, 2026
Root cause is known; the fix is being deprioritized because it cannot be made cleanly on our side today.
Root cause. Both the recorder (
key-input-dialog.vue→getAcceleratorFromKeyboardEvent) and the runtime matcher (electronLocalshortcut'sbefore-input-eventhandler) run the samenormalizeKeyboardEventfrom@hfelix/electron-localshortcut's atom-keymap port. It keeps Shift as a modifier only for non-character keys and upper-case Latin letters; for shifted digits/punctuation it records the shifted character instead (Shift+7 →&). With a primary modifier held, the OS reports the base character (⌘⇧7 → key7), so neither the shifted character nor Shift survives. Hence two symptoms from one cause: the recorder savesCmd+7, and even a hand-writtenCmd+Shift+7never fires, because a physical ⌘⇧7 also normalizes tocmd+7.Why it is parked. The library is a fork whose last commit is 2022-02-20 and whose sole npm maintainer is the fork owner, so an upstream release is not reachable. The bug cannot be worked around outside the library either — ⌘⇧7 and ⌘7 collapse to the same normalized event, so the matcher cannot tell them apart. That leaves a
patch-packagepatch (attempted in #4873, now closed) or vendoring the library into the repository (1423 LOC, MIT,debugas its only dependency, noelectronimport), which is a standalone refactor rather than a bug fix.Labelling as low priority and upstream-blocked. Anyone picking this up should take the vendoring route; the one-line normalization fix and its unit test are preserved on the
fix/keybinding-recorder-shift-4863branch.