Codex CLI Composer & Input Shortcuts
The composer is the text area at the bottom of the Codex interface, and it carries the tool's only true keyboard shortcuts — including the Enter-versus-Tab distinction that has no equivalent in any editor, because no editor has an agent already working while you type.
| Action | Windows | Mac | Description |
|---|---|---|---|
| Steer the running turn | Enter (while the agent is working) | Enter | Injects your message into the turn already in progress, changing what the agent is doing immediately. This is the control for urgent corrections — a wrong file, a wrong assumption, a command you do not want run. |
| Queue a follow-up prompt | Tab (while the agent is working) | Tab | Holds your message until the current turn finishes, then delivers it as the next instruction. The right choice for anything that should happen after the present work rather than instead of it. |
| Insert a newline without sending | Ctrl+J | Ctrl+J | Adds a line break inside the composer instead of submitting. Shift+Enter works in some terminals and not others because of how they encode the keypress, which is why Ctrl+J is the binding to rely on. |
| Open the prompt in your editor | Ctrl+G | Ctrl+G | Hands the current composer contents to whatever VISUAL or EDITOR points at, and takes back what you save. The practical answer for a long or structured prompt, since the composer is not a text editor and does not pretend to be. |
| Edit your previous message | Esc Esc (composer empty) | Esc Esc | Double-pressing Escape on an empty composer reopens your last message for editing, and continuing to press walks further back through the transcript. Useful when a prompt was misread and rewording beats explaining. |
| Navigate draft history | Up / Down | Up / Down | Steps back through earlier composer drafts, restoring their text and any image placeholders they carried. Distinct from Esc Esc, which edits messages you actually sent rather than drafts you typed. |
| Attach a file with @ | @ then Tab or Enter | @ then Tab or Enter | Typing @ opens a fuzzy search across the workspace; accepting a match attaches that file to the conversation. Far more reliable than describing a path in prose and hoping the agent locates the right thing. |
| Run a local shell command with ! | !command | !command | Executes the command on your machine outside Codex's sandbox and shows you the output — without sending any of it to the model. The way to check something for yourself mid-session without spending context on it. |
| Attach an image | Paste into the composer, or -i at launch | Paste into the composer, or -i at launch | Screenshots can be pasted straight into the composer in terminals that support it, or attached at launch with the -i flag. Useful for a failing UI or an error dialog where describing the problem takes longer than showing it. |
Start with steering, because it is the binding that most changes how the tool feels once you understand it. While the agent is running, Enter sends your message straight into the turn in progress, altering what it is doing immediately. Tab holds the message until the current turn completes, then delivers it as the next instruction. The distinction maps cleanly onto intent: 'stop, that is the wrong file' is an Enter, 'after that, update the changelog' is a Tab. Neither is destructive, but choosing wrong is frustrating in a specific way — a correction sent with Tab arrives after the mistake it was supposed to prevent.
Newline insertion is Ctrl+J, and this is the single most-searched thing about Codex CLI's input handling. Shift+Enter is what almost everyone tries, and it works in some terminals and not others. The reason is not Codex: terminals differ in whether they transmit a distinguishable sequence for Shift+Enter at all, so in many of them the application receives something indistinguishable from a plain Enter and sends the message. Ctrl+J transmits an actual line-feed character that every terminal passes through identically, which is why it works everywhere.
For anything longer than a few lines, Ctrl+G is the better answer than either. It hands the composer contents to whatever VISUAL or EDITOR points at — Vim, Emacs, VS Code, whatever you have configured — and takes back what you save. The composer is not a text editor and does not try to be, so a carefully-structured prompt with sections and examples is much less painful written in a real one. This is also the route to reuse: a prompt drafted in your editor can be saved before it is sent.
Esc pressed twice on an empty composer reopens your previous message for editing, and continuing to press walks further back through the transcript. This is more useful than it sounds. When the agent has misread a prompt, rewording the original is often better than adding a clarification, because a clarification leaves the ambiguous instruction in the conversation where it continues to exert influence. The Up and Down arrows do something adjacent but different — they step through composer drafts you typed, restoring text and image placeholders, rather than messages you actually sent.
Three prefix characters change what the composer does with what follows. Typing @ opens a fuzzy file search across the workspace; accepting a match attaches that file to the conversation, which is far more reliable than describing a path in prose and hoping the agent finds the right thing. Typing ! runs the rest of the line as a shell command on your machine, outside the sandbox, showing you the output without sending any of it to the model. And typing / opens the slash-command popup, which is where most of Codex's functionality actually lives.
The ! prefix deserves a second look because both halves of its behaviour matter. Outside the sandbox means it runs with your permissions in your shell — the boundary constraining the agent does not constrain you here, so the usual care applies. Not sent to the model means checking something costs you nothing in context. A quick git log, a directory listing, a test run you want to see yourself: all free, where asking the agent to look would consume tokens and add noise to the conversation.
Images round the set out. Screenshots paste directly into the composer in terminals that support it, and the -i flag attaches them at launch. For a broken UI, an error dialog, or a design you want implemented, showing is faster and less lossy than describing — and this is one of the clearer cases where the terminal interface is not the limitation it appears to be.
The slash-command popup deserves a mention as an input mechanism rather than a list of features. Typing / filters as you type, so you do not need to remember exact command names — a fragment usually gets you there, and the popup shows what each one does as you scroll. In effect it is the discoverability layer a terminal application would otherwise lack, and it is the reason Codex can ship several dozen commands without a manual. Typing /help lists everything your specific binary supports, which matters because the set has grown between releases.
A final observation about the composer as a whole. Almost every genuine key binding here exists because typing is happening concurrently with work, which is not a situation traditional software design has had to solve. Steering versus queueing, editing a message you already sent, attaching a file without breaking your line of thought, running a command whose output the model never sees — each of these is an answer to the same underlying question of how a person stays in control of something that is already in motion. Read that way the composer's small keymap is more coherent than it first appears.