opencode Keyboard Shortcuts
Keyboard shortcuts for opencode, the open-source terminal AI coding agent, on MacWindowsLinux. opencode uses a leader key (Ctrl+X by default): for those shortcuts you press the leader, release, then the next key. Built from opencode's official keybind table.
App & Leader Key
| Action | Shortcut |
|---|---|
| Leader key — prefix for the chorded shortcuts below | CtrlXCtrlXCtrlX |
| Quit opencode | CtrlCCtrlCCtrlC |
| Quit opencode (leader chord) | Ctrl+X then QCtrl+X then QCtrl+X then Q |
| Open the command palette | CtrlPCtrlPCtrlP |
| Open the current prompt in your editor | Ctrl+X then ECtrl+X then ECtrl+X then E |
| Toggle the sidebar | Ctrl+X then BCtrl+X then BCtrl+X then B |
| Switch theme | Ctrl+X then TCtrl+X then TCtrl+X then T |
| Open the status view | Ctrl+X then SCtrl+X then SCtrl+X then S |
| Suspend opencode to the shell | CtrlZCtrlZCtrlZ |
Sessions
| Action | Shortcut |
|---|---|
| New session | Ctrl+X then NCtrl+X then NCtrl+X then N |
| List / switch sessions | Ctrl+X then LCtrl+X then LCtrl+X then L |
| Interrupt the running model | EscapeEscapeEscape |
| Compact the session (summarize to free context) | Ctrl+X then CCtrl+X then CCtrl+X then C |
| Export the session | Ctrl+X then XCtrl+X then XCtrl+X then X |
| Rename the session | CtrlRCtrlRCtrlR |
| Open the session timeline | Ctrl+X then GCtrl+X then GCtrl+X then G |
| Copy the last message | Ctrl+X then YCtrl+X then YCtrl+X then Y |
| Undo the last message | Ctrl+X then UCtrl+X then UCtrl+X then U |
| Redo the last message | Ctrl+X then RCtrl+X then RCtrl+X then R |
Models & Agents
| Action | Shortcut |
|---|---|
| List / switch models | Ctrl+X then MCtrl+X then MCtrl+X then M |
| List providers | CtrlACtrlACtrlA |
| Toggle favorite for the current model | CtrlFCtrlFCtrlF |
| Cycle to a recent model | F2F2F2 |
| List / switch agents | Ctrl+X then ACtrl+X then ACtrl+X then A |
| Cycle agent | TabTabTab |
| Cycle agent (reverse) | ShiftTabShiftTabShiftTab |
| Cycle the model variant | CtrlTCtrlTCtrlT |
Input & Line Editing
| Action | Shortcut |
|---|---|
| Submit your message | EnterEnterEnter |
| New line without sending | ShiftEnterShiftEnterShiftEnter |
| New line (alternate) | CtrlJCtrlJCtrlJ |
| Move to start of line | CtrlACtrlACtrlA |
| Move to end of line | CtrlECtrlECtrlE |
| Delete to end of line | CtrlKCtrlKCtrlK |
| Delete to start of line | CtrlUCtrlUCtrlU |
| Delete the previous word | CtrlWCtrlWCtrlW |
| Move one word forward | AltFAltFAltF |
| Move one word backward | AltBAltBAltB |
| Undo typing | CmdZCtrlZCtrl- |
| Redo typing | CmdShiftZCtrl.Ctrl. |
| Paste | CtrlVCtrlVCtrlV |
Slash & Custom Commands
| Action | Shortcut |
|---|---|
| Show help | /help/help/help |
| Generate an AGENTS.md project file | /init/init/init |
| Undo the last change | /undo/undo/undo |
| Redo the last change | /redo/redo/redo |
| Share the session (get a URL) | /share/share/share |
| Reference a file in a custom command | @filename@filename@filename |
| Inject shell output in a custom command | !command!command!command |
| Pass arguments to a custom command | $ARGUMENTS$ARGUMENTS$ARGUMENTS |
No shortcuts found. Try a different search term.
Frequently Asked Questions
How do I quit opencode?
Press Ctrl+C or Ctrl+D to exit. opencode also binds quit to its leader chord: press Ctrl+X (the default leader key), release, then press Q. The leader chord trips up newcomers because it's a two-step sequence, not a simultaneous combo — Ctrl+X first, then Q.
How do I stop opencode while it's generating a response?
Press Escape to interrupt the running model. This is different from Ctrl+C — in opencode, Ctrl+C exits the app (or clears the input box), while Escape cancels the in-progress generation without quitting.
What is the leader key in opencode?
The leader key is a prefix for many of opencode's shortcuts, set to Ctrl+X by default. To use a leader shortcut you press Ctrl+X, release it, then press the next key — for example Ctrl+X then N starts a new session, and Ctrl+X then M opens the model list. The leader key is configurable in your opencode config.
How do I add a new line in opencode without sending?
Press Shift+Enter to insert a new line without submitting. opencode also accepts Ctrl+J and Alt+Enter for the same thing. Note that Shift+Enter can require a small terminal-config tweak in some terminals (for example Windows Terminal) to be passed through correctly.
How do I switch models or agents in opencode?
Press Ctrl+X then M to open the model list, or Ctrl+X then A for the agent list. You can also cycle agents directly with Tab (and Shift+Tab to go backward), cycle recent models with F2, and switch model variants with Ctrl+T.
Is opencode the same as Claude Code?
No. opencode is an open-source, provider-agnostic terminal AI coding agent from sst (you can point it at different model providers), while Claude Code is Anthropic's. They're in the same terminal-TUI category and share ideas like sessions and slash commands, but they're separate projects with different keybinds — opencode's leader-key system being the most visible difference.