[BUG] Shift+Enter inserts literal CSI u-protocol sequence instead of newline
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 pressing Shift+Enter in Claude Code while using WezTerm with enhanced keyboard protocols enabled (enable_kitty_keyboard and enable_csi_u_key_encoding), the literal character sequence [13;2u is inserted instead of a newline.
What Should Happen?
Shift+Enter should insert a newline character, allowing multi-line input in Claude Code.
Steps to Reproduce
- Enable enhanced keyboard protocols in WezTerm:
``lua``
config.enable_kitty_keyboard = true
config.enable_csi_u_key_encoding = true
- Launch Claude Code in WezTerm
- Press Shift+Enter in the input area
- Observe that
[13;2uis inserted instead of a newline
The sequence [13;2u is a CSI u-protocol code representing:
- 13 = Enter key (carriage return)
- 2 = Shift modifier
- u = CSI u-protocol terminator
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.35 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Other
Additional Information
The CSI u-protocol (also known as "fixterms" or "kitty keyboard protocol") is an enhanced keyboard encoding protocol that provides more detailed information about key events. The sequence ESC[13;2u should be decoded by the application as "Shift+Enter" and handled appropriately.
Workaround: Add a WezTerm key binding that sends a plain newline for Shift+Enter:
{ 'Enter', 'SHIFT', act.SendString('\n') }
However, this prevents users from benefiting from enhanced keyboard protocols in their shell/editor configurations.
Claude Code's input handler should properly decode CSI u-protocol sequences, particularly for common key combinations like Shift+Enter. This would ensure compatibility with modern terminal emulators that use enhanced keyboard protocols by default.
Additional details:
- WezTerm version: 20240203-110809-5046fc22
- macOS version: Darwin 25.0.0
- Regular Enter (without Shift) works correctly
- This issue likely affects other terminal emulators with enhanced keyboard protocol support (e.g.,
kitty,foot,ghostty)
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗