Skip to main content

Keybinds

Keybinds (keyboard shortcuts) let you customize how you interact with the opencode terminal user interface. You can rebind default shortcuts, create new shortcuts for custom commands, and configure navigation patterns.

Configuration

Keybinds are configured in tui.json under the keybinds object.

{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"leader": "ctrl+x",
"command_list": "ctrl+p",
"switch_agent": "tab",
"variant_cycle": "ctrl+t"
}
}

Custom keybinds are merged with the built-in defaults. You only need to specify the shortcuts you want to change.

Using OPENCODE_TUI_CONFIG

If your tui.json is in a non-standard location:

export OPENCODE_TUI_CONFIG=/path/to/custom/tui.json

Leader Key

The leader key is a prefix key that creates namespaced multi-key shortcuts. Press and release the leader key, then press the next key to trigger the action.

{
"keybinds": {
"leader": "ctrl+x"
}
}

Leader Timeout

The leader_timeout setting controls how long (in milliseconds) opencode waits for the second key after the leader is pressed:

{
"keybinds": {
"leader": "ctrl+x",
"leader_timeout": 2000
}
}

Default is 2000ms (2 seconds). If the second key is not pressed within this window, the leader key is treated as a regular input.

Default Keybindings

Leader Prefix Shortcuts (Ctrl+X by default)

All shortcuts below use the leader key as a prefix unless otherwise noted.

ShortcutActionDescription
Leader + CcompactToggle compact mode
Leader + EeditorOpen current file in external editor
Leader + QexitQuit opencode
Leader + XexportExport conversation to markdown
Leader + MmodelsOpen model picker
Leader + NnewStart a new session
Leader + RredoRedo last undone action
Leader + LsessionsShow session list
Leader + TthemesOpen theme picker
Leader + UundoUndo last action
Leader + Downsession_downNavigate to child session
Leader + Upsession_upNavigate to parent session
Leader + Rightsession_nextCycle to next sibling session
Leader + Leftsession_prevCycle to previous sibling session

Direct Shortcuts (no leader prefix)

ShortcutActionDescription
Ctrl+Pcommand_listOpen command palette
Tabswitch_agentCycle through available agents
Ctrl+Tvariant_cycleCycle through model variants

All Keybind Actions

Action IDDefault BindingDescription
compactLeader + CToggle compact UI mode
editorLeader + EOpen current file in system editor
exitLeader + QQuit opencode
exportLeader + XExport current session as markdown
modelsLeader + MOpen model selection picker
newLeader + NCreate a new conversation session
redoLeader + RRedo the last undone change
sessionsLeader + LShow session management panel
themesLeader + TOpen theme picker
undoLeader + UUndo the last change
session_downLeader + DownNavigate into child session
session_upLeader + UpNavigate to parent session
session_nextLeader + RightCycle to next sibling session
session_prevLeader + LeftCycle to previous sibling session
command_listCtrl+POpen the command palette
switch_agentTabSwitch to the next configured agent
variant_cycleCtrl+TCycle through model variants
find(none)Search within the current session
scroll_up(none)Scroll the view up
scroll_down(none)Scroll the view down
page_up(none)Scroll up one page
page_down(none)Scroll down one page
goto_top(none)Scroll to the top of the session
goto_bottom(none)Scroll to the bottom of the session
copy(none)Copy selected text
paste(none)Paste from clipboard
cancelEsc or Ctrl+CCancel current operation
confirmEnterConfirm current selection/prompt

Custom Keybind Examples

Vim-Style Navigation

{
"keybinds": {
"leader": "ctrl+space",
"leader_timeout": 1500,
"session_down": "ctrl+j",
"session_up": "ctrl+k",
"session_next": "ctrl+l",
"session_prev": "ctrl+h"
}
}

Minimalist Setup

{
"keybinds": {
"leader": "ctrl+x",
"command_list": "ctrl+space",
"switch_agent": "ctrl+a",
"variant_cycle": "ctrl+v"
}
}

Emacs-Inspired

{
"keybinds": {
"leader": "ctrl+z",
"leader_timeout": 3000,
"undo": "ctrl+/",
"redo": "ctrl+?",
"find": "ctrl+s"
}
}

Function Key Layout

{
"keybinds": {
"models": "f1",
"themes": "f2",
"sessions": "f3",
"command_list": "f4",
"switch_agent": "f5",
"variant_cycle": "f6"
}
}

Session Navigation

Session navigation shortcuts let you move through the session tree — a directed graph of parent-child conversations.

Session Tree Structure

Main Session (root)
├── Follow-up question (child)
│ └── Deeper investigation (grandchild)
├── Alternative approach (child)
└── Bug fix task (child)
└── Test verification (grandchild)
ActionDescription
session_downEnter the currently selected child session
session_upReturn to the parent session
session_nextCycle to the next sibling session
session_prevCycle to the previous sibling session

Example: To navigate to a child session and back:

Leader + Down → enter child
Leader + Up → return to parent
Leader + Right → go to next sibling
Leader + Left → go to previous sibling

Keybind Syntax

Keys are specified as strings using the following syntax:

PatternExampleDescription
ctrl+<key>ctrl+pControl key combination
alt+<key>alt+bAlt (Meta) key combination
shift+<key>shift+enterShift key combination
<key>tab, f1, escSingle key (function keys, arrows, etc)
Leader + <key>built-inLeader prefix sequence (configurable)

Valid key names:

  • Modifiers: ctrl, alt, shift, meta
  • Printable keys: a-z, 0-9, space, -, =, [, ], \, ;, ', ,, ., /, `
  • Special keys: tab, enter, esc, backspace, delete, home, end, pageup, pagedown, up, down, left, right
  • Function keys: f1 through f24

Keybind Override Precedence

When multiple keybind configurations apply, the priority is:

  1. tui.json keybinds (highest)
  2. User theme-level keybinds
  3. Built-in defaults (lowest)

Only the first matching keybind for any given action is used.

Unbinding a Default Shortcut

To disable a default keybind without replacing it:

{
"keybinds": {
"switch_agent": null
}
}

Setting an action to null removes its keybinding entirely. The action can still be triggered via the command palette.

Binding Multiple Keys to the Same Action

{
"keybinds": {
"command_list": ["ctrl+p", "f4"]
}
}

Provide an array of key strings to bind multiple shortcuts to the same action.

Checking Active Keybinds

To view all active keybindings (merged defaults + custom):

/help

Or from the CLI:

opencode config show

The active configuration display includes the resolved keybindings.