Skip to content

Bug: Paste (and other hotkeys) broken with dvorak layout #8255

@jimrandomh

Description

@jimrandomh

Lexical version: 0.42.0

Steps To Reproduce

  1. 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)
  2. Set your keyboard layout to English/Dvorak
  3. Put something in your clipboard
  4. 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.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions