Every Codex CLI Keyboard Shortcut (June 2026)

A verified Codex CLI keyboard shortcut reference: cancel and interrupt keys, newline with Ctrl+J, Ctrl+G external editor, Ctrl+R history search, Esc Esc to edit, Shift+Tab approval modes, and terminal fixes.

TL;DR

The Codex CLI runs almost entirely from the keyboard. The keys you actually reach for every day: Esc interrupts a running turn, Ctrl+J inserts a newline that survives any terminal, Ctrl+G opens your $EDITOR for a long prompt, Ctrl+R searches your prompt history, Esc Esc rewinds to edit an earlier message, and Shift+Tab cycles approval modes (Read-only, Auto, Full Access). When in doubt inside a live session, type /keymap to print the bindings your installed build actually ships.

Version note (as of June 2026): this guide is written against Codex CLI v0.135.x, the line OpenAI shipped through May 2026. Codex iterates fast and a few bindings are version-gated (noted below), so /keymap in your session is always the final word.

Who this is for

  • Developers who run codex daily and want to stop editing long prompts one character at a time.
  • People who write multi-paragraph specs and keep accidentally submitting them half-finished.
  • Anyone running long agent tasks who needs to interrupt, redirect, or rewind without losing context.
  • Teams writing an internal Codex onboarding doc.
  • Users whose keys behave differently in iTerm2, Apple Terminal, the VS Code terminal, Warp, or tmux.

The shortcuts worth memorizing first

If you learn nothing else, learn these. They cover roughly 90% of real Codex CLI sessions.

ShortcutWhat it doesNotes
EscInterrupt the current model turn or tool callStops the run; does not undo file edits
Ctrl+JInsert a newline in the composerMost reliable newline across terminals
Ctrl+GOpen the prompt in your $EDITOR / $VISUALBest way to draft a long spec
Ctrl+RReverse-search your prompt historyv0.121.0+; Enter accepts, Esc cancels
Esc EscEdit your previous message (composer empty)Keep pressing to walk back; Enter forks
Shift+TabCycle approval modes in-sessionRead-only → Auto → Full Access
TabQueue a follow-up for the next turnDoes not interrupt the current turn
Enter (while running)Inject new instructions mid-turnCodex reads it without losing context
Ctrl+LRedraw the screenKeeps your context intact
? / /keymapShow the active bindingsThe source of truth for your build

Session control: interrupt, exit, rewind

ShortcutDetail
EscInterrupts the current turn or tool call. Use it the moment a run drifts.
Ctrl+CCancels input; press twice to quit the session. You can also type /exit or /quit.
Ctrl+DExits when the composer is empty; press twice to force-quit.
Esc EscWith an empty composer, edits your previous user message. Keep pressing Esc to walk further back through the transcript, then press Enter to fork the conversation from that point.
Ctrl+LRedraws the terminal when long output garbles the screen. It does not clear Codex context.
Ctrl+OCopies Codex’s most recent completed output to the clipboard.

The most important distinction: Esc stops the current turn, but neither Esc nor Ctrl+C rolls back files Codex already wrote. To undo edits, tell Codex explicitly (“revert your changes to src/auth.ts”) or inspect git diff and discard yourself. If you fork with Esc Esc, you change the conversation, not the files on disk.

Approval and automation modes

Codex CLI ships three approval modes. Cycle them mid-session with Shift+Tab, or set one explicitly with the /approvals command (some builds expose it as /permissions).

ModeWhat Codex may doWhen to use it
Read-onlyBrowse and read files, propose a plan; no edits, no commandsFirst look at an unfamiliar repo; planning
Auto (default)Read, edit, and run commands inside the working directory; asks before touching anything outside it or using the networkDay-to-day work in a repo you trust
Full AccessWork across the machine, including network access, without askingIsolated containers or throwaway VMs only

Rule of thumb: read-only to plan, Auto for normal work, Full Access only inside a sandbox you can throw away. Auto is the safe default precisely because it confines writes to the working directory and still gates network and out-of-tree actions behind a prompt.

Composing prompts: newlines, editor, files, shell

This is where Codex saves the most time, and where terminals cause the most friction.

Shortcut / tokenWhat it does
Ctrl+JInsert a newline without sending. The most reliable multiline key across terminals.
Shift+EnterAlso inserts a newline, but only if your terminal forwards the combo. If it submits instead, use Ctrl+J.
Ctrl+GOpens the current draft in your $EDITOR / $VISUAL. Best for anything longer than a couple of lines.
@Fuzzy file search; pick a file to attach its path/content to the message.
!Run a local shell command and feed the output into the conversation.
-i / --imageAttach an image (e.g. a screenshot of an error).

For a real spec, don’t fight terminal keymaps. Either press Ctrl+G to draft in your editor, or write the spec in a file and tell Codex to read it:

Read TASK.md and implement it. Stop and ask before changing the database schema.

Input editing (readline / Emacs style)

The composer follows readline conventions, so most shell editing habits transfer directly.

ShortcutMeaning
Ctrl+AMove to start of line
Ctrl+EMove to end of line
Ctrl+B / Ctrl+FMove back / forward one character
Option+B / Alt+BMove back one word (Option must send Meta on macOS)
Option+F / Alt+FMove forward one word
Ctrl+UDelete everything before the cursor
Ctrl+KDelete everything after the cursor
Ctrl+WDelete the previous word
Ctrl+YYank (paste back) the last killed text
Ctrl+H / BackspaceDelete the previous character

Since v0.135.0, the TUI also supports Vim-style text-object editing when Vim mode is enabled in your config, which adds word/line motions on top of these readline defaults.

Reasoning depth, history, menus

ShortcutMeaning
Alt+, / Alt+.Lower / raise reasoning depth for the next turn (v0.124.0+)
Ctrl+RReverse-search prompt history; Enter accepts, Esc cancels (v0.121.0+)
Up / DownNavigate draft history in the composer
TabComplete a slash command or path; queues a follow-up turn while Codex works
EnterSubmit, or inject instructions into the running turn
EscClose a menu, or interrupt the active task

Raising reasoning depth (Alt+.) before a hard refactor gives Codex more thinking budget; lowering it (Alt+,) speeds up trivial edits.

Slash commands you’ll use often

Shortcuts handle editing; slash commands handle the session. The ones worth knowing:

CommandWhat it does
/keymapPrint the active keymap for your build (settles every “which key?” question)
/approvalsSwitch approval mode (also /permissions in some builds)
/modelSwitch the underlying model
/initGenerate an AGENTS.md project context file
/diffShow the working-tree diff Codex has produced
/compactSummarize and shrink the context to free up window
/reviewAsk Codex to review the current changes
/exit, /quitEnd the session

When shortcuts fail

SymptomCauseFix
Option+B/F prints odd charactersOption isn’t sending MetaEnable “Use Option as Meta key” (Apple Terminal) or “Esc+” (iTerm2)
Shift+Enter submits instead of newlineTerminal doesn’t forward the comboUse Ctrl+J instead, or draft with Ctrl+G
Ctrl+S freezes outputTerminal flow control paused the streamPress Ctrl+Q; to disable permanently, stty -ixon
Esc Esc does nothingComposer isn’t empty, or build predates itClear the input first; check /keymap
Alt+, / Alt+. ignoredBuild older than v0.124.0Update Codex CLI
Cmd shortcuts do nothingYou’re in a pure terminal, not an app surfaceUse the terminal Ctrl / Alt equivalents

iTerm2 and Apple Terminal both work cleanly once Option is mapped to Meta. tmux, screen, and some VS Code integrated-terminal builds remap meta/alt keys. When a key misbehaves, test it in plain Terminal.app to isolate whether it’s Codex or your terminal.

Codex CLI vs Claude Code

The two tools share readline editing keys (Ctrl+A, Ctrl+E, Ctrl+R) and the “press Esc to interrupt” reflex, and both ship an Esc Esc rewind. But the slash commands and product-level bindings differ: Codex uses /approvals and /keymap; Claude Code has its own set such as /terminal-setup. Don’t assume a binding from one carries to the other. In Codex, /keymap is the authoritative list for your installed version. For a deeper comparison, see Codex vs Claude Code.

FAQ

Q: What’s the difference between Esc and Ctrl+C in Codex? A: Esc interrupts the current model turn or tool call while keeping the session alive, ideal when a run heads the wrong way. Ctrl+C cancels the current input; pressed twice on an empty composer it quits the session entirely. Neither rolls back files Codex already edited, so use git diff or ask Codex to revert.

Q: How do I enter a newline without sending the prompt? A: Press Ctrl+J. It’s the most reliable newline across terminals. Shift+Enter also works if your terminal forwards the combo, but many don’t. For anything longer than a few lines, press Ctrl+G to draft in your $EDITOR instead.

Q: Can I edit a message I already sent? A: Yes. With an empty composer, press Esc Esc to edit your previous user message. Keep pressing Esc to walk further back through the transcript, then press Enter to fork the conversation from that point. This rewinds the conversation, not the files on disk.

Q: How do I switch approval modes without restarting? A: Press Shift+Tab to cycle Read-only, Auto, and Full Access mid-session, or run /approvals (or /permissions on some builds) to set one explicitly. Auto is the default and confines writes to the working directory.

Q: Which terminals are most likely to break Codex shortcuts? A: tmux, screen, and some VS Code integrated-terminal builds remap meta/alt keys, breaking Option+B/F and Shift+Enter. iTerm2 and Apple Terminal work cleanly once you enable “Use Option as Meta key”. When in doubt, test in plain Terminal.app first, and fall back to Ctrl+J for newlines.

Tags: #AI coding #Codex #Tutorial