fix: restore event.code fallback for macOS Option+letter shortcuts#58
Closed
fix: restore event.code fallback for macOS Option+letter shortcuts#58
Conversation
The isSingleLetterKey check used /^\p{Letter}$/u which matched all Unicode
letters, blocking the event.code fallback for macOS Option+letter combinations
like Option+A (å), Option+P (π), Option+S (ß), etc.
Changes:
- match.ts: only skip the code fallback for ASCII letters OR non-ASCII letters
without Alt key. Non-ASCII letters produced while Alt is held (macOS Option
combos) now fall through to the event.code fallback as expected.
- constants.ts: fix normalizeKeyName to not uppercase letters whose toUpperCase()
returns multiple chars (e.g. ß → SS), which would otherwise break the length
checks in the matching logic.
- match.test.ts: add regression tests for macOS Option+letter shortcuts.
Co-authored-by: KevinVandy <28243511+KevinVandy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix regression with isSingleLetter check for Mac options
fix: restore event.code fallback for macOS Option+letter shortcuts
Mar 9, 2026
@tanstack/angular-hotkeys
@tanstack/hotkeys
@tanstack/hotkeys-devtools
@tanstack/preact-hotkeys
@tanstack/preact-hotkeys-devtools
@tanstack/react-hotkeys
@tanstack/react-hotkeys-devtools
@tanstack/solid-hotkeys
@tanstack/solid-hotkeys-devtools
@tanstack/vue-hotkeys
@tanstack/vue-hotkeys-devtools
commit: |
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.
PR #53 introduced
isSingleLetterKeyusing/^\p{Letter}$/u, which matches all Unicode letters. This blocked theevent.codefallback for macOS Option+letter combos — Option+A firesevent.key='å', which is a Unicode letter, so the early return fired andAlt+Ahotkeys stopped working. Same forπ,ø,ƒ,ç,ß,µ,æ,œ, and their shift variants.🎯 Changes
src/match.ts— narrow the early-return guard:A-Z): always trust the layout (Dvorak/Colemak/AZERTY preservation, unchanged)event.codefallback ← the fixsrc/constants.ts— fixnormalizeKeyNamefor letters whose.toUpperCase()expands to multiple chars:'ß'.toUpperCase()→'SS'(2 chars), which broke theeventKey.length === 1guard downstreamtests/match.test.ts— regression tests for the affected Option+letter and Option+Shift+letter combinations.✅ Checklist
pnpm run test:pr.🚀 Release Impact
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.