Lexical version: 0.42.0
Steps To Reproduce
- Be on a system where the Paste hotkey is Ctrl+V (ie Windows or some flavors of Linux, but not MacOS where it's Cmd+V)
- Set your keyboard layout to English/Dvorak
- Put something in your clipboard
- Focus a Lexical editor (the playground will do) and press Ctrl+V to paste
The current behavior
In ShortcutsPlugin/shortcuts.ts, keyboard events are matched with hotkeys based on KeyboardEvent.code. MDN's documentation of that property describes it as:
The KeyboardEvent.code property represents a physical key on the keyboard (as opposed to the character generated by pressing the key). In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
The hotkeys in ShortcutsPlugin take precedence over default browser hotkeys, because in ShortcutsPlugin/index.ts, if a hotkey is matched it calls preventDefault.
The "superscript" hotkey is Ctrl+., but using KeyboardEvent.code. In the case of English/dvorak, the V letter is in the position that on QWERTY keyboards was .; the practical upshot of which is that for dvorak users, the Superscript hotkey is Ctrl+V and there is no usable hotkey for paste.
The expected behavior
Either the hotkeys in ShortcutsPlugin should use KeyboardEvent.key rather than KeyboardEvent.code so that they reflect the dvorak keyboard layout, or keyboard events should be checked using KeyboardEvent.key against a list of builtin hotkeys that should take precedence over them.
(I don't know how any of this interacts with non-English languages and the hotkey-internationalization story might be pretty complicated.)
Lexical version: 0.42.0
Steps To Reproduce
The current behavior
In
ShortcutsPlugin/shortcuts.ts, keyboard events are matched with hotkeys based onKeyboardEvent.code. MDN's documentation of that property describes it as:The hotkeys in
ShortcutsPlugintake precedence over default browser hotkeys, because inShortcutsPlugin/index.ts, if a hotkey is matched it callspreventDefault.The "superscript" hotkey is
Ctrl+., but usingKeyboardEvent.code. In the case of English/dvorak, theVletter is in the position that on QWERTY keyboards was.; the practical upshot of which is that for dvorak users, the Superscript hotkey is Ctrl+V and there is no usable hotkey for paste.The expected behavior
Either the hotkeys in
ShortcutsPluginshould useKeyboardEvent.keyrather thanKeyboardEvent.codeso that they reflect the dvorak keyboard layout, or keyboard events should be checked usingKeyboardEvent.keyagainst a list of builtin hotkeys that should take precedence over them.(I don't know how any of this interacts with non-English languages and the hotkey-internationalization story might be pretty complicated.)