Skip to content

Fix Alt+letter preview shortcuts on macOS#2055

Merged
frankrousseau merged 2 commits into
cgwire:mainfrom
NicoPennec:fixes
Jun 17, 2026
Merged

Fix Alt+letter preview shortcuts on macOS#2055
frankrousseau merged 2 commits into
cgwire:mainfrom
NicoPennec:fixes

Conversation

@NicoPennec

@NicoPennec NicoPennec commented Jun 16, 2026

Copy link
Copy Markdown
Member

Problem

  • On macOS, Option/Alt rewrites the typed character (Option+K → '˚'), so Alt+letter preview shortcuts matched on event.key were all dead on a Mac.
  • Some npm dependencies are outdated.

Solution

  • Fix macOS shortcuts:
    • Add a shared isAltLetter helper that matches on the typed letter (event.key) when it is a plain a-z character, and falls back to event.code only when the OS rewrote it (macOS Option) or the layout is non-Latin.
    • Reuse the helper in SharedPlaylistPlayer's own keydown handler so Alt+J/K match identically.
  • Bump npm dependencies.

@NicoPennec NicoPennec marked this pull request as draft June 16, 2026 10:37
macOS Option rewrites the typed character (Option+K → '˚'), so matching
Alt+letter shortcuts on event.key alone left them dead on a Mac. Resolve
the letter by event.key when it is a plain letter — reliable on every
Windows/Linux layout, AZERTY/BÉPO/Dvorak included — and fall back to
event.code (the physical key) only when the OS rewrote it to a glyph, as
on macOS. Guard with !mod (ctrl/meta) so Windows AltGr and macOS
Cmd+Option chords don't fire them.

Preferring event.key also avoids a physical-position clash on BÉPO under
Windows/Linux, where the 'J' key sits on the QWERTY 'P' position and 'O'
on 'R': a plain event.code match fired Alt+P / Alt+R there instead of the
intended shortcut. The match is a shared isAltLetter helper, reused by
SharedPlaylistPlayer's Alt+J/K.

Known limitation — macOS + non-QWERTY: on macOS the Option modifier
rewrites event.key on every layout, so the match always falls back to
event.code (physical QWERTY position) there. On layouts that relocate
these letters (BÉPO, Dvorak) the macOS shortcut therefore keys off
physical position, not the printed cap, so Alt+letter can be dead or hit
a neighbouring shortcut (e.g. BÉPO's 'J' cap is physical KeyP, so Option+J
matches Alt+P). Recovering the cap letter would need
navigator.keyboard.getLayoutMap(), which Safari/Firefox don't expose. A
test pins this behaviour so the trade-off is explicit; Windows/Linux is
unaffected.
@NicoPennec NicoPennec marked this pull request as ready for review June 17, 2026 10:15
@frankrousseau frankrousseau merged commit 0710156 into cgwire:main Jun 17, 2026
5 checks passed
@NicoPennec NicoPennec deleted the fixes branch June 18, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants