Fixing Cmd+Enter to Insert Newline in Hermes TUI Under Kitty
Problem
In the Hermes TUI (and other prompt_toolkit-based CLIs like Claude Code), pressing Cmd+Enter in Kitty terminal triggers Kitty’s default new_os_window action, opening a new terminal window instead of inserting a newline in the prompt.
The desired behavior: Cmd+Enter inserts a newline (same as in browser form fields), and Enter alone submits the prompt.
Root Cause
Kitty intercepts Cmd+Enter at the terminal level before it reaches the foreground application. The default mapping opens a new OS window. The application never sees the keypress.
Fix
Add one line to ~/.config/kitty/kitty.conf:
map cmd+enter send_text all \e\n
This overrides Kitty’s default and sends Escape + newline (\e\n) to the foreground process. prompt_toolkit interprets \n (0x0a) as “insert newline” in multiline mode, and submits only on \r (0x0d, carriage return – what plain Enter sends).
Verification
Tested using Kitty’s remote control API:
- Launch a fresh Kitty instance with
allow_remote_control yes - Run
cat -vin the foreground - Send
cmd+enterviakitty @ send-key cmd+enter - Confirm: foreground process receives
\n, no new window created
Requirements
- Kitty 0.46.1 or later
- Full restart required:
Cmd+Qand relaunch. Config reload (Cmd+Shift+F5) is insufficient forcmdmodifier mappings.
What Does NOT Work
| Attempt | Result |
|---|---|
disable_enhanced_keyboard_protocol all |
Kitty 0.46.1 does not recognize this option |
disable_enhanced_keyboard_protocol hermes |
Not a valid option; also, hermes is a python3 script so kitty sees python3 as the process name |
map cmd+enter send_text all \r\n |
\r\n submits the prompt in most TUIs |
map cmd+enter combine \e \n |
combine merges kitty actions, not raw bytes |
Config reload only (Cmd+Shift+F5) |
cmd modifier mappings require full restart |
Alternative: Ctrl+J
If Cmd+Enter cannot be remapped, Ctrl+J sends a literal \n (0x0a) that prompt_toolkit interprets as “insert newline.” This works without any kitty config changes.
Related
- Kitty keyboard protocol (CSI u): Enhanced keyboard protocol sends modified keys as escape sequences like
[106;9u. Some TUI frameworks (prompt_toolkit) do not interpret these. If present, addmap ctrl+j send_text all \nas an additional override. - Karabiner Elements: Can remap
Cmd+Enterat the OS level to an unused key (e.g., F20), which Kitty then maps to\n.
[No columns defined in frontmatter]
Want to stay in touch? You can reach me in a variety of ways from my Contact page.