Limit physical key fallback to non-Latin layout output #4469
main fromrefs/pull/4469/head·merged by juliusmarminge View on GitHubWhat Changed#
Shortcut matching only falls back to the physical KeyA-KeyZ position when the layout-derived key is not itself a Latin letter. Two regression tests cover a non-Latin layout (still matched by position) and a remapped Latin layout (matched by layout output only).
Why#
resolveEventKeys accepted both the layout key and the physical code for every keypress. On a remapped Latin layout one physical key then triggered shortcuts for two different letters at once: with a layout where physical D types "a", a mod+D binding fires on mod+A and the user can no longer select all text.
The physical fallback exists for a real reason (Cyrillic and other non-Latin layouts, plus Option-modified symbols on macOS, produce keys that ASCII-defined shortcuts can never match), so it stays for exactly those cases: when event.key is not a Latin letter. When the layout already types Latin letters it speaks the shortcut vocabulary and is trusted alone.
Fixes #4434
Testing#
vp test run apps/web/src/keybindings.test.tspasses (43/43), including the existing Option-modifiedKeyBcase and the two new layout tests- Related suites (shortcutModifierState, KeybindingsSettings.logic, projectScriptKeybindings) pass (17/17)
pnpm typecheckin apps/web cleanvp linton changed files clean
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Note
Low Risk Localized change to shortcut resolution with targeted tests; behavior shift only affects remapped Latin layouts where layout and physical labels disagreed.
Overview
Keyboard shortcuts no longer treat physical KeyA–KeyZ position as an extra match when the layout already types a Latin letter.
resolveEventKeys still falls back to event.code for non-Latin output (e.g. Cyrillic) and macOS Option symbols, but remapped Latin layouts (physical D typing a) only match on the layout character—so mod+D no longer fires on mod+A and system shortcuts like select-all are not shadowed.
Two tests cover Cyrillic-on-physical-D still resolving diff.toggle, and remapped Latin keys matching by layout output only.
Note
Limit physical key code fallback in resolveEventKeys to non-Latin layout output#
Previously, resolveEventKeys always added the physical letter derived from event.code as a fallback candidate, which caused shortcuts to fire incorrectly when the keyboard layout produced a different Latin letter than the physical key label (e.g. key 'a' on a key with code KeyD would match a binding for 'd').
- The fallback to the physical key letter is now only applied when the layout key is not a Latin a–z character, so non-Latin layouts (e.g. Cyrillic) still resolve shortcuts correctly via physical key.
- Latin layouts that remap keys (e.g. Dvorak-style remapping) no longer trigger shortcuts for the wrong key.
- Behavioral Change: events where the layout produces a Latin letter but on a physically different key will no longer match bindings for the physical key's label.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved
Straightforward bug fix adding a regex guard to prevent physical key fallback when the layout already outputs a Latin letter. Change is well-scoped, clearly documented, and includes tests covering both the fix and preserved behavior for non-Latin layouts.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this664499c
juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
c9f01ff5-d076-453e-ab16-df23466324acYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share