Recover Ctrl+<letter> and Escape under a CJK IME (keyCode 229) - #6066
Open
openwong2kim wants to merge 1 commit into
Open
Recover Ctrl+<letter> and Escape under a CJK IME (keyCode 229)#6066openwong2kim wants to merge 1 commit into
openwong2kim wants to merge 1 commit into
Conversation
When a CJK IME is active, Windows/Chromium reports keyCode 229 for keys it has claimed, including control inputs that never begin a composition. Those were dropped: CompositionHelper.keydown swallowed every 229 keydown, and evaluateKeyboardEvent switches on keyCode so Escape and Ctrl+<letter> never matched. Recover the real keyCode from the physical code for these inputs (Escape, Ctrl+letter, Ctrl+Space) and let them through the composition gate, leaving printable/composable keys untouched.
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.
Fixes #6065
What
While a CJK IME is active, Windows/Chromium delivers control inputs with
keyCode === 229("Process") even though they never begin a composition.Ctrl+<letter>,Ctrl+Space, and a bareEscapeare then silently dropped — nothing reachesonData. Inside an in-pane TUI this shows up asCtrl+Jnot inserting a newline,Ctrl+Cnot interrupting, andEscapenot cancelling; the same keys work with the IME off.Root cause and measurements are in #6065. In short, two keyCode-based paths combine:
CompositionHelper.keydownreturnsfalsefor everykeyCode === 229keydown, so_keyDownbails before the encoder runs. That assumes a laterinput/composition event will carry the key — true for printable characters, but control chords produce neither.evaluateKeyboardEventswitches onkeyCode, so229matches neither Escape (case 27) nor theCtrl+<letter>derivation (keyCode 65..90).The physical
ev.codeis correct throughout, so it's used to recover the intended key.Changes
common/input/Keyboard.ts— addrecoverImeControlKeyCode(ev): whenkeyCode === 229, mapev.codeback to a real keyCode for the masked control inputs (Escape→ 27; with Ctrl held,KeyA..KeyZ→ 65..90 andSpace→ 32).evaluateKeyboardEventuses the recovered value for itsswitchand for theCtrl+<letter>/Ctrl+Spacecases in thedefaultbranch. Printable/composable keys keepkeyCode === 229and are left to the composition path.browser/input/CompositionHelper.ts— in the non-composingkeyCode === 229branch, let control inputs (ev.code === 'Escape', orev.ctrlKey && !ev.altKey && !ev.metaKey) continue to the normal key handler (return true) instead of being swallowed. A smallisImeControlPassthroughpredicate mirrors the recovery scope.Both are gated on the control-key conditions, so genuine IME composition — which never involves Ctrl, and for a bare key produces an
input/composition event — is unaffected.Testing
Keyboard.test.ts: new cases assertingCtrl+J→\n,Ctrl+C→\x03,Ctrl+Space→\x00,Escape→\x1batkeyCode 229; that a plain composable key at 229 still yields no key; and that real keyCodes are unaffected.CompositionHelper.test.ts: new cases assertingkeydownreturnstrue(passthrough) for a Ctrl chord and for Escape atkeyCode 229.Keyboard+CompositionHelpersuites pass (77 tests).tsgobuild clean;oxlint --type-awareand the naming ESLint config clean on both changed files.lib/xterm.mjsin Chromium (dispatches keydowns withkeyCodeforced to 229): stock emits nothing for all four control inputs; with the fix they emit the correct bytes and a plain composing key still emits nothing.onDataonData0a03001bNotes
Scoped to
Ctrl+<letter>,Ctrl+Space, andEscape— the inputs with confirmed field reports.Alt/Metachords are derived fromkeyCodein the same branch and are plausibly affected; left out here to keep the change conservative, easy to add if wanted.