[BUG] Held arrow keys produce raw escape sequences in iTerm2 (kitty keyboard protocol repeat events not handled)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using Claude Code in iTerm2 3.5.9, holding down arrow keys to move the cursor produces raw escape sequences instead of cursor movement. Characters like [1;1:2D appear inline in the input.
Potential root case:
Claude Code requests the kitty keyboard protocol from the terminal (CSI > u), but does not properly handle key repeat events. In the kitty protocol, repeat events are encoded with event type :2 as a sub-parameter
(e.g., \e[1;1:2D for a repeated left arrow). Claude Code appears to handle the initial key press but not subsequent repeats, causing the raw sequences to leak through as visible text.
What Should Happen?
Cursor moves left continuously while the key is held.
Error Messages/Logs
Steps to Reproduce
- Use iTerm2 3.5.9 (stable) with default settings
- Launch claude in the terminal
- Type some text in the input field
- Hold down the left arrow key to move the cursor backward
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.56
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
Workaround: ~~In iTerm2, go to Settings → Profiles → Keys → General and uncheck "Allow application to change how keys are reported". This prevents Claude Code from enabling the kitty keyboard protocol, so iTerm2 continues sending standard xterm sequences which are handled correctly.~~
UPD: Seems like this workaround breaks multi line edit in Claude (Every message will be automatically sent using Enter or Shift+Enter). I've tried to play with Claude configs, but no luck.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗