Ctrl+<letter> and Escape are silently dropped under a CJK IME (keyCode 229)
Details
- xterm.js version: 6.0.0, also reproducible on current
master - Browser/Environment: Chromium on Windows 11 (hit in an Electron app, reproduced in plain Chromium via the built
lib/xterm.mjs) - OS: Windows 11
- IME: Korean (Microsoft IME). The same mechanism applies to any CJK IME (Japanese, Chinese) that reports
keyCode === 229for claimed keys.
Summary
While a CJK IME is active, control inputs that never begin a composition — Ctrl+<letter>, Ctrl+Space, and a bare Escape — are silently dropped. Nothing reaches onData, so nothing reaches the PTY. The clearest user-visible symptoms inside an in-pane TUI:
Ctrl+J(insert-newline in readline / Claude Code / codex editors) does nothing.Ctrl+Cdoes not interrupt.Escapedoes not cancel (e.g. a dialog whose footer says "Esc to cancel" can only be dismissed by killing the process).
Turn the IME off and the exact same keys work. Native terminals (Windows Terminal / conhost) are unaffected because they don't route through a browser textarea + composition events — this is specific to the xterm.js renderer.
Steps to reproduce
- On Windows, switch to a CJK IME (e.g. Korean Microsoft IME) so it is active (not in alphanumeric passthrough).
- Open any xterm.js instance and focus it.
- Press
Ctrl+J,Ctrl+C, orEscape. - Observe
term.onData— nothing is emitted.
A self-contained dynamic repro (Node + playwright-core, drives the real built bundle and dispatches keydowns with keyCode forced to 229 the way a CJK IME does) is attached at the bottom.
Measured (stock 6.0.0)
| keydown | code | ctrl | keyCode | onData |
|---|---|---|---|---|
| Ctrl+J (IME) | KeyJ | yes | 229 | (nothing) |
| Ctrl+C (IME) | KeyC | yes | 229 | (nothing) |
| Ctrl+Space (IME) | Space | yes | 229 | (nothing) |
| Escape (IME) | Escape | no | 229 | (nothing) |
| Ctrl+J (no IME) | KeyJ | yes | 74 | 0a |
| Escape (no IME) | Escape | no | 27 | 1b |
Root cause
When a CJK IME claims a key, Windows/Chromium delivers the keydown with keyCode === 229 (the "Process" code) instead of the real value, even for control chords that never open a composition. Two keyCode-based code paths then combine to drop the event:
1. CompositionHelper.keydown swallows every 229 keydown. For a non-composing keydown it hits:
if (ev.keyCode === 229) {
// non-composition character (eg. numbers and punctuation) with IME active
this._handleAnyTextareaChanges();
return false;
}
return false makes CoreBrowserTerminal._keyDown bail before ever calling the keyboard encoder. That path assumes any 229 keydown resolves through a later input/composition event — which is true for printable characters but not for control chords (Ctrl+J, Escape): they produce no input event and no composition, so they're lost.
2. evaluateKeyboardEvent is keyed entirely on keyCode. Even if the event reached it, the switch (ev.keyCode) never matches: Escape is case 27, and Ctrl+<letter> is derived in the default branch from ev.keyCode >= 65 && ev.keyCode <= 90 → String.fromCharCode(ev.keyCode - 64). With keyCode === 229 both fail and no byte is produced.
This is the same underlying issue reported for character loss/duplication under keyCode-229 IMEs (#5887, #6045), but for control keys the failure mode is a total drop rather than a mangled character. The physical ev.code is populated correctly throughout (KeyJ, Escape), so it can be used to recover the intended key.
Impact
Any CJK user (Korean/Japanese/Chinese) running an in-pane TUI that relies on Ctrl+<letter>, Ctrl+Space, or a bare Escape — which is most of them: readline, vim insert→normal, fzf, less, and AI coding TUIs (Claude Code, codex) that use Ctrl+J/Ctrl+Enter for newline-without-submit. The keys work with the IME off and break with it on, which is a confusing, hard-to-attribute failure for end users.
Suggested fix
Recover the intended key from the physical ev.code for exactly the control inputs that get masked, leaving printable/composable keys on the composition path untouched:
- In
CompositionHelper.keydown, for a non-composingkeyCode === 229keydown, let control inputs (ev.ctrlKey && !ev.altKey && !ev.metaKey, orev.code === 'Escape') continue to the normal key handler instead of being swallowed. - In
evaluateKeyboardEvent, whenkeyCode === 229, recover the realkeyCodefromev.code(Escape→ 27,KeyA..KeyZ→ 65..90,Space→ 32) before the switch, so Escape and theCtrl+<letter>/Ctrl+Spacederivations resolve normally.
Both are gated on the control-key conditions above, so genuine IME composition (which never involves Ctrl and, for a bare key, produces an input/composition event) is unaffected. Happy to put up a PR — a working branch with unit tests and the dynamic repro is ready.
Notes
- Scoped deliberately to
Ctrl+<letter>,Ctrl+Space, andEscape, the inputs with confirmed field reports.Alt/Metachords are derived fromkeyCodein the samedefaultbranch and are plausibly affected too, but were left out of the initial fix to keep it conservative; they can be added if there's demand.
Standalone dynamic repro (Node + playwright-core)
Run from an xterm.js checkout that has lib/xterm.mjs built (npm run esbuild-package) and playwright-core in node_modules:
node repro-ime-229.mjs
It serves a page that loads the real built bundle, creates a Terminal, dispatches synthetic keydowns to the hidden textarea with keyCode forced to 229 (as a CJK IME does), and prints what onData emitted. On stock 6.0.0 every 229 row prints (nothing); with the fix, Ctrl+J→0a, Ctrl+C→03, Ctrl+Space→00, Escape→1b, while a plain composing key still emits nothing. Full script content is in the PR branch.