fix(renderer): gate cmd shortcuts on physical key code, not character#6
Conversation
|
@claude review this |
🚨 Preview Deployment Blocked - Security ProtectionYour pull request was blocked from triggering preview deployments Why was this blocked?
How to resolve this:Option 1: Get Collaborator Access (Recommended) Option 2: Request Permission Override For Repository Administrators:To disable this security check ( This security measure protects against malicious code execution in preview deployments. Only trusted collaborators should have the ability to trigger deployments. 🛡️ Learn more about this security featureThis protection prevents unauthorized users from:
Preview deployments are powerful but require trust. Only users with repository write access can trigger them. |
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.