Terminal displays raw escape sequences `[57358u` when Caps Lock is pressed (VS Code integrated terminal, kitty keyboard protocol)

Resolved 💬 8 comments Opened Mar 26, 2026 by doo13gil Closed Apr 18, 2026

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

  1. Open Claude Code in VS Code integrated terminal
  2. 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:

  1. Open VS Code
  2. Open Command Palette: Cmd + Shift + P
  3. Search for "Preferences: Open Keyboard Shortcuts (JSON)" and select it
  4. 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"
}
  1. 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.

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗