[lexical-playground] Bug Fix: Use isExactShortcutMatch for Dvorak keyboard compatibility#8260
Merged
etrepum merged 3 commits intofacebook:mainfrom Mar 28, 2026
Conversation
…patibility The playground's ShortcutsPlugin was using KeyboardEvent.code (physical key position) to match shortcuts, which breaks on non-QWERTY layouts like Dvorak. For example, Ctrl+V (paste) would trigger the Superscript shortcut because the physical V key maps to '.' on Dvorak. Refactor all shortcut matchers to use isExactShortcutMatch from the core library, which was introduced in facebook#8155 to handle this correctly. It uses event.key (logical character) for matching, with a fallback to event.code only for non-ASCII keyboard layouts. Fixes facebook#8255
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
When Shift is held, event.key becomes '>' and '<' instead of '.' and ','
Contributor
Author
|
font size shortcuts were matching on |
etrepum
approved these changes
Mar 28, 2026
Collaborator
etrepum
left a comment
There was a problem hiding this comment.
It might be worth having a windows user verify if the symbol based shortcuts still work as expected (such as ctrl+shift+, to decrease font size) when using a keyboard layout like one of the japanese ones where the ',' and '.' keys are remapped to something like 'ね' and 'る'
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.
Summary
ShortcutsPluginto useisExactShortcutMatch(from the corelexicalpackage) instead of manualKeyboardEvent.codechecksisExactShortcutMatch, which usesevent.key(logical character) instead ofevent.code(physical position), but the playground code was still using the old approachThe Problem
On Dvorak layout, pressing Ctrl+V (paste) would trigger the Superscript shortcut because the physical V key is at the position where
.(Period) is on QWERTY. TheShortcutsPluginwas checkingevent.code === 'Period'which matches the physical key position regardless of layout.The Fix
All shortcut matcher functions in
shortcuts.tsnow useisExactShortcutMatch(event, key, modifierMask)which:event.key(logical character) case-insensitively for standard keysevent.codeonly for non-ASCII keyboard layouts (e.g., Russian) whereevent.keyis non-ASCIIThe heading shortcut handler in
index.tsxwas also updated to useevent.key(which directly gives'1','2','3') instead of extracting the digit fromevent.code(e.g.,'Digit1').Test plan
Fixes #8255