[BUG] Arrow keys produce [57319u in Ghostty terminal on Linux (Kitty keyboard protocol)
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?
- Terminal: Ghostty (Linux, GTK)
- OS: Ubuntu 24.04 (kernel 6.14.0-37-generic)
- Shell: Bash
- Issue: Arrow keys (up/down/left/right) do not work inside Claude Code CLI. Pressing down arrow prints
[57319uinstead of navigating. Arrow keys work fine in the normal Ghostty shell — the issue only occurs inside Claude Code.
This is the same class of bug as #17040 (numpad Enter producing [57414;129u). Claude Code enables the Kitty keyboard protocol but does not correctly parse the CSI u encoded arrow key sequences that Ghostty sends back.
Attempted Workarounds (none worked)
term = xterm-256colorin Ghostty configkeybind = arrow_up=text:\x1b[A(with and withoutunconsumed:andperformable:prefixes)enquiry-response =in Ghostty configTERM=dumb claudewrapper- Bash function wrapper:
claude() { TERM=xterm-256color command claude "$@"; }
None of these work because Claude Code requests the Kitty protocol directly from the terminal, bypassing Ghostty's keybind overrides.
Workaround: j/k keys work for navigation in vim mode (/vim).
What Should Happen?
Arrow keys should navigate up/down in Claude Code CLI, same as they do in the regular terminal shell.
Error Messages/Logs
[57319u
(57319 = Unicode codepoint for down arrow in Kitty keyboard protocol CSI u encoding)
Steps to Reproduce
- Open Ghostty terminal on Ubuntu 24.04
- Launch
claude(native CLI, v2.1.29) - Press up or down arrow key
- Observe
[57319u(down) or[57352u(up) printed instead of navigation
Claude Model
Opus 4.5
Is this a regression?
Unknown
Claude Code Version
2.1.29
Platform
Anthropic API
Operating System
Ubuntu 24.04 LTS (Linux 6.14.0-37-generic)
Terminal/Shell
Ghostty + Bash
Additional Information
Related: #17040, #17919
Same root cause as https://github.com/google-gemini/gemini-cli/issues/6227 (Gemini CLI had identical bug, fixed by properly parsing CSI u sequences)
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗