Terminal displays raw escape sequences `[57358u` when Caps Lock is pressed (VS Code integrated terminal, kitty keyboard protocol)
Description
When pressing Caps Lock in VS Code's integrated terminal while Claude Code is running, raw escape sequences [57358u (and similar) appear in the prompt/input area.
Root Cause
Claude Code requests kitty keyboard protocol (ESC[?u) from the terminal on startup. VS Code's xterm.js honors this request, and subsequently reports Caps Lock as ESC[57358u]. VS Code settings (shellIntegration, keyboard.dispatch, allowChords, etc.) cannot block the protocol upgrade once the running application requests it.
Environment
- OS: macOS (darwin 25.3.0)
- Terminal: VS Code integrated terminal
- Claude Code version: v2.1.84
- Input method: Korean (한국어) — Caps Lock used for input source switching
Steps to Reproduce
- Open Claude Code in VS Code integrated terminal
- Press Caps Lock
Expected Behavior
No visible escape sequence output.
Actual Behavior
[57358u appears inline in the terminal input area.
Workaround
Use Terminal.app or iTerm2 instead of VS Code integrated terminal (these do not support kitty protocol and ignore the upgrade request)
---
✅ Solution Found (~1 minute fix)
Add the following keybinding to your VS Code keybindings.json:
Steps:
- Open VS Code
- Open Command Palette:
Cmd+Shift+P - Search for "Preferences: Open Keyboard Shortcuts (JSON)" and select it
- Inside the
[]array, add the following entry (add a comma after the previous}if other entries already exist):
{
"key": "capslock",
"command": "workbench.action.terminal.focus",
"when": "terminalFocus"
}
- Save with
Cmd+S— no VS Code restart needed.
Why this works: This keybinding intercepts the Caps Lock key event when the terminal is focused and remaps it to a harmless "focus terminal" command, preventing xterm.js from forwarding the raw kitty protocol escape sequence ([57358u) into the input. The system-level IME language switch (Korean ↔ English, or any other input source) still works normally via macOS.
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗