fix(renderer): gate cmd shortcuts on physical key code, not character#6
Open
nguyenthienthanh wants to merge 1 commit into
Open
Conversation
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.
Problem
Typing Vietnamese (Telex via EVKey) into a remote Slack tab could yank focus to the URL bar mid-word. Typing
chayjwas fine, butchajy— which forces a mid-syllable tone rewrite — broke: the next keystrokes landed in the address bar instead of the chat.Root cause
The only path that focuses the URL bar is the Cmd+L shortcut, and on focus it
select()s the URL — so subsequent keystrokes overwrite it. The global hotkey handler matched shortcuts one.key(the produced character). When EVKey fixes a word mid-syllable it re-posts characters as synthetic key events (CGEvent) that can carry a stray Cmd flag with a non-physical key — whiche.keymatching misread as Cmd+L.Proof:
chajycontains no physicalLkey, so the only waycase "l"fires is an event whosee.key === "l"but whose physical key isn't L — the signature of a synthetic injection.Fix
Match the letter/punctuation Cmd-shortcuts on the physical
e.code("KeyL") instead ofe.key— the convention already used byisOsReservedKey, the ⌥N handler, and Cmd+1..9 ("Match on e.code — Option rewrites e.key"). A real Cmd+L always carriese.code === "KeyL"; the synthetic injection does not, so it falls through and is forwarded to the remote page untouched. Also fixes the iPadOS uppercase-e.keyedge the old comment called out.No shortcuts added/removed/changed — only the matching logic. Converted: ⌘K, ⌘⇧T, ⌘⌥L, and the main switch (T/W/D/L/S/R/F/C/V/A +
,[]).Test
pnpm typecheckclean.chajy,toán,nghiệminto remote Slack — focus stays in the chat, no jump to the URL bar. All Cmd shortcuts still work from a real keyboard.