Codex TUI prompt Feature: Shift+Enter to support newline in codex interactive prompt
Resolved 💬 14 comments Opened Jan 2, 2026 by NikkiAung Closed Jul 21, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
What feature would you like to see?
Support Shift+Enter to insert a newline in the interactive TUI prompt (multi‑line input without submitting).
Proposal :
Keybinding Shift+Enter should insert a newline. At the same time, when there is no text/prompt in the codex interactive TUI, it should disable Shift+Enter to avoid accidental blank lines; spacing tokenization percentage cost.
Problem :
As of now, when users wanna enter newline with Shift+Enter, it's just prompting to AI Codex, not going to newline. This could be annoyance to users with large prompt willing to go to next new line.
Additional information
Demo of Shift+Enter not entering new line. :)
https://github.com/user-attachments/assets/b5b84e2d-17a9-4504-a6b3-5a7ea0ff08be
14 Comments
@etraut-openai, feel free to lmk about my proposal! Im super excited to contribute! :)
Codex needs to run in many different terminal emulators and across multiple platforms. Earlier versions of Codex supported Shift+Enter, but this caused problems with many terminal emulators. After investigating potential solutions, we switched to Ctrl+J as the key binding for entering newlines. This works across all terminals and platforms.
bring back shift + enter! ctrl+j is annoying
Also feeling the same way, but this also applied in Claude Code CLI. Hopefully, they would bring back in future! :))
Lmk what u guys think of the below feat as well, @SocialNerd42069 and @faev999!
https://github.com/openai/codex/issues/8709
we should at least be able to choose between the two (or have both ideally). maybe allowing for custom keybindings would help a lot here.
<img width="1156" height="314" alt="Image" src="https://github.com/user-attachments/assets/f85e42f5-fb39-42f0-bd3b-8f36d49ce403" />
shift+enteris also still highlighted as the command still when using?to show the shortcuts (using TUI2).That's fair enough, keep Ctrl+J as the default.
Please add the option to change newline to Shift + Enter for those of us who's terminals emulators allow us to do that.
Avoid Control Button Please!
If supporting Shift+Enter is difficult, then please consider Option+Enter or Command+Shift+Enter instead. Ctrl+J is a really poor choice.
What happens if, for some reason, the same developer ends up using Codex on both Ubuntu and macOS in the future?
At the very least, Command+J would be a better option.
The Ctrl key is disliked by many macOS users :)
I just paid for the subscription. I can't believe this is the key binding! ctrl+j for me is down arrow because of vim bindings. who chooses these things?
@etraut-openai please make this mappable.. ctrl-j is not tmux friendly
Can we please just get back shift+enter? Or make the broken terminals fix it via /keymap? Why break most of your existing users?
It would be great if this was configurable in
config.toml.Ctrl+J is very counter intuitive, at least consider Ctrl+Enter
Quick note from a deeper dive on the Windows Terminal angle of this — there's a Windows-specific manifestation that's slightly different from what's been discussed.
I ran
crossterm's key-event capture on Windows Terminal pressing Shift+Enter, plain Enter, Ctrl+J, Ctrl+M, and Ctrl+Enter. Result:| Keypress | crossterm event |
|---|---|
| Shift+Enter |
KeyCode::Enter + CONTROL|| Ctrl+Enter |
KeyCode::Enter + CONTROL← identical || Plain Enter |
KeyCode::Enter(no mods) || Ctrl+J |
KeyCode::Char('j') + CONTROL|| Ctrl+M |
KeyCode::Char('m') + CONTROL|Two takeaways:
insert_newlinedefaults matchKeyCode::Enter + CONTROL— defaults checkChar('j')+CTRL,Char('m')+CTRL,plain Enter,shift Enter,alt Enter. So the actual event Windows Terminal delivers matches none of them, and the keystroke either submits (via composer'ssubmit_keys) or gets eaten depending on context.This explains why the
~/.codex/config.tomlworkaround circulating in #4218 and elsewhere (insert_newline = ["ctrl-j", "ctrl-m", "enter", "shift-enter", "alt-enter"]) doesn't reliably help on Windows Terminal: it's identical to the defaults. None of the bindings in that list catch the actualEnter+CONTROLevent.@joshka-oai's observation in #3024 is exactly right — many terminals collapse Shift+Enter into other signals.Ctrl+Jis the official cross-platform answer. This patch is consistent with that pattern; it just addsEnter+CONTROL(Windows Terminal's collapsed event) to the same set thatCtrl+Jalready lives in.Proposed fix
Branch: https://github.com/jacobhallgren/codex/tree/fix/win-shift-enter
codex-rs/tui/src/keymap.rs:ctrl(KeyCode::Enter)toeditor.insert_newlinedefaults under#[cfg(windows)]. Catches both Shift+Enter and Ctrl+Enter on Windows Terminal (they're indistinguishable anyway). Linux/macOS unchanged —shift(KeyCode::Enter)already handles those via the kitty protocol.validate_no_shadowallowed_overlapslist with the same key/action pair, so users who rebindcomposer.submit = ctrl-enter(per #5716) still pass the runtime conflict check. This mirrors the existing entry that already permitsplain Enterto live in bothcomposer.submitandeditor.insert_newline.Diff size: 1 file, 59 insertions, 22 deletions. Targeted tests pass:
cargo test -p codex-tui --lib keymap(95/95).On the broader picture
This is one of (at least) three different platform-specific manifestations of the same surface symptom; each needs its own targeted fix:
shift(KeyCode::Enter)matches. ✓modifyOtherKeysmode 2 (\x1b[>4;2m), so tmux strips the SHIFT modifier. See the analysis at #21699 —@fcoury-oaimentioned a fix is in flight there.Enter+CTRL(Windows console quirk). My branch above addresses this one.Happy to open a PR per CONTRIBUTING.md if a maintainer wants to invite. Otherwise the branch is public and the diff is small enough to be picked up under another author if that fits the workflow better.
The keybinding for this action is now editable. You can use
/keymapto assign whatever keybinding you prefer. This allows you to select a binding that's compatible with your terminal emulator.