Skip to content

Keyboard Shortcuts Reference

Print this page and stick it next to your monitor - muscle memory in three days


📝 Course Notes

Key takeaways from this lesson:

Keyboard Shortcuts Reference Notes


Leader Key

OpenCode uses a Leader Key to avoid conflicts with terminal shortcuts.

Default Leader Key: Ctrl+X

Usage: Press Ctrl+X, release, then press the second key.


TUI Shortcuts

Basic Operations

ShortcutActionDescription
EnterSend messageSend current input
Shift+EnterNew lineAdd newline in input box
TabSwitch AgentCycle through primary agents
Shift+TabReverse switchReverse cycle through primary agents
EscapeInterruptStop current AI response
Ctrl+CClear inputClear input box content
Ctrl+DExitClose OpenCode
Ctrl+PCommand listOpen command palette

Leader Key Operations

ShortcutActionDescription
LeadernNew sessionSame as /new
LeaderlSession listSame as /sessions
LeadermModel listSame as /models
LeaderaAgent listSelect Agent
LeadertTheme listSame as /themes
LeadereEditorOpen external editor
LeadercCompactCompact current session context
LeaderuUndoUndo last change
LeaderrRedoRedo last undo
LeaderxExportExport current session
LeadersStatusView status
LeaderbSidebarToggle sidebar display
LeadergTimelineSession timeline
LeaderyCopyCopy message
LeaderhHide detailsToggle details display
LeaderqQuitClose OpenCode
Ctrl+BRun in backgroundMove a synchronously running sub-Agent into the background

Diff Viewer

Enter /diff or open the diff viewer from the command palette. diff_open has no default binding, but you can configure one. The viewer is enabled by default and supports a file tree, file and hunk navigation, single or all patches, unified and split views, workspace changes, and changes from the latest AI turn. When the current branch is not the default branch, you can also compare it with the main branch.

ShortcutAction
Esc / qClose and return to the previous screen
TabSwitch focus between the file tree and patch pane
] / [Next/previous hunk
n / pNext/previous file
bShow/hide the file tree
sSwitch between a single patch and all patches
dSwitch diff source
vSwitch between split and unified views
mMark or unmark a file as reviewed
?Show full help

Session Navigation

ShortcutActionDescription
Child sessionSwitch to child Agent session
Reverse childReverse cycle child sessions
Parent sessionReturn to parent session

Message Scrolling

ShortcutAction
Page UpScroll up one page
Page DownScroll down one page
Ctrl+Alt+UScroll up half page
Ctrl+Alt+DScroll down half page
Ctrl+G / HomeJump to top
Ctrl+Alt+G / EndJump to bottom

Input Area Operations

ShortcutAction
Ctrl+AMove cursor to line start
Ctrl+EMove cursor to line end
Ctrl+BMove cursor back one character
Ctrl+FMove cursor forward one character
Alt+BMove cursor back one word
Alt+FMove cursor forward one word
Ctrl+KDelete to end of line
Ctrl+UDelete to start of line
Ctrl+WDelete previous word
Alt+DDelete next word
Ctrl+DDelete current character
/ Browse input history

Model Switching

ShortcutAction
F2Cycle recent models
Shift+F2Reverse cycle
Ctrl+TCycle variants

Permission Confirmation

ShortcutAction
yAllow
nDeny
aAlways allow (this session)

IDE Extension Shortcuts

VS Code / Cursor

Shortcut (macOS)Shortcut (Win/Linux)Action
Cmd+EscCtrl+EscOpen OpenCode panel
Cmd+Shift+EscCtrl+Shift+EscNew session
Cmd+Option+KAlt+Ctrl+KInsert file reference

Desktop Input Shortcuts

The OpenCode desktop app input supports Readline/Emacs-style shortcuts. These are built in and cannot be configured through opencode.json:

ShortcutAction
Ctrl+AMove to line start
Ctrl+EMove to line end
Ctrl+BMove cursor back one character
Ctrl+FMove cursor forward one character
Alt+BMove cursor back one word
Alt+FMove cursor forward one word
Ctrl+DDelete character under cursor
Ctrl+KDelete to end of line
Ctrl+UDelete to start of line
Ctrl+WDelete previous word
Alt+DDelete next word
Ctrl+TTranspose characters
Ctrl+GCancel popup / interrupt response

Custom Shortcuts

Configure a flat keybinds map in the standalone tui.json or tui.jsonc:

json
{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
    "leader": "ctrl+x",
    "session_new": "<leader>n",
    "session_list": "<leader>l",
    "model_list": "<leader>m"
  }
}

Disable Shortcuts

Set a binding to "none" or false to disable it:

json
{
  "keybinds": {
    "session_compact": false
  }
}

Multiple Key Bindings

Separate multiple keys with commas:

json
{
  "keybinds": {
    "app_exit": "ctrl+c,ctrl+d,<leader>q"
  }
}

Configuration Locations and Migration

The loading order is: the global configuration directory, OPENCODE_TUI_CONFIG, ordinary project tui.json / tui.jsonc, .opencode directories along the path, and OPENCODE_CONFIG_DIR. Later sources take priority. Ordinary project files are applied from the root side toward the current directory, so the nearest one wins. Multiple .opencode directories are merged from the current side toward the root, so on conflicts the rootmost directory is loaded later and wins. OPENCODE_CONFIG_DIR is loaded last.

During an upgrade, starting the TUI checks the global configuration, project configurations found along the path, configuration directories, and the old main configuration specified by OPENCODE_CONFIG. It migrates their theme, keybinds, and tui fields into a tui.json in the same directory. Migration is skipped if the target tui.json exists; a tui.jsonc alone does not block migration. Old fields are removed only after the new file has been written and a .tui-migration.bak has been created or reused. The main configuration no longer reads these fields.

Cursor Appearance

cursor is a sibling of keybinds. Its style supports block, underline, line, and default; blinking controls whether it blinks. default preserves the terminal setting and ignores blinking.

Common Configurable Key Bindings

Source: v1.18.22 keybind.ts

New entries: background sessions, Skills, and cursor

Basic Bindings

Key NameDefaultDescription
leaderctrl+xLeader key
app_exitctrl+c,ctrl+d,<leader>qExit
diff_opennoneOpen the diff viewer

Session Management

Key NameDefaultDescription
session_new<leader>nNew session
session_list<leader>lSession list
session_export<leader>xExport session
session_interruptescapeInterrupt response
session_backgroundctrl+bMove a synchronous sub-Agent into the background
session_compact<leader>cCompact context
session_timeline<leader>gTimeline
session_child_cyclerightCycle child sessions
session_child_cycle_reverseleftReverse cycle child sessions
session_parentupReturn to parent session
session_forknoneFork session
session_renamectrl+rRename session
session_deletectrl+dDelete session
session_sharenoneShare session
session_unsharenoneUnshare session

Model & Agent

Key NameDefaultDescription
model_list<leader>mModel list
model_cycle_recentf2Cycle recent models
model_cycle_recent_reverseshift+f2Reverse cycle recent models
model_cycle_favoritenoneCycle favorite models
model_cycle_favorite_reversenoneReverse cycle favorite models
variant_cyclectrl+tCycle model variants
agent_list<leader>aAgent list
agent_cycletabCycle agents
agent_cycle_reverseshift+tabReverse cycle agents
prompt_skillsnoneOpen the Skill picker

Diff Viewer

Key NameDefaultDescription
diff_closeescape,qClose the viewer
diff_toggleenter,spaceExpand or select an item
diff_expand / diff_collapseright / leftExpand or collapse an item
diff_expand_allEExpand all directories
diff_switch_focustabSwitch focus
diff_next_hunk / diff_previous_hunk] / [Next/previous hunk
diff_next_file / diff_previous_filen / pNext/previous file
diff_toggle_file_treebToggle the file tree
diff_single_patchsSwitch between one and all patches
diff_switch_sourcedSwitch source
diff_toggle_viewvSwitch between split and unified views
diff_help?Show help

m is the viewer's built-in “mark as reviewed” shortcut and is not a keybinds setting.

Interface Control

Key NameDefaultDescription
theme_list<leader>tTheme list
editor_open<leader>eOpen editor
sidebar_toggle<leader>bToggle sidebar
scrollbar_togglenoneToggle scrollbar
status_view<leader>sStatus view
tool_detailsnoneTool details
command_listctrl+pCommand palette
tips_toggle<leader>hToggle tips display

Message Operations

Key NameDefaultDescription
messages_undo<leader>uUndo
messages_redo<leader>rRedo
messages_copy<leader>yCopy
messages_toggle_conceal<leader>hToggle detail hiding
messages_nextnoneNext message
messages_previousnonePrevious message
messages_last_usernoneJump to last user message
messages_page_uppageup,ctrl+alt+bPage up
messages_page_downpagedown,ctrl+alt+fPage down
messages_half_page_upctrl+alt+uHalf page up
messages_half_page_downctrl+alt+dHalf page down
messages_firstctrl+g,homeJump to top
messages_lastctrl+alt+g,endJump to bottom

Input Box Operations

Key NameDefaultDescription
input_submitreturnSubmit
input_newlineshift+return,ctrl+return,alt+return,ctrl+jNew line
input_clearctrl+cClear input
input_pastectrl+vPaste
input_move_leftleft,ctrl+bMove cursor left
input_move_rightright,ctrl+fMove cursor right
input_move_upupMove cursor up
input_move_downdownMove cursor down
input_select_leftshift+leftSelect left
input_select_rightshift+rightSelect right
input_select_upshift+upSelect up
input_select_downshift+downSelect down
input_line_homectrl+aLine start
input_line_endctrl+eLine end
input_select_line_homectrl+shift+aSelect to line start
input_select_line_endctrl+shift+eSelect to line end
input_visual_line_homealt+aVisual line start
input_visual_line_endalt+eVisual line end
input_select_visual_line_homealt+shift+aSelect to visual line start
input_select_visual_line_endalt+shift+eSelect to visual line end
input_buffer_homehomeBuffer start
input_buffer_endendBuffer end
input_select_buffer_homeshift+homeSelect to buffer start
input_select_buffer_endshift+endSelect to buffer end
input_delete_linectrl+shift+dDelete line
input_delete_to_line_endctrl+kDelete to line end
input_delete_to_line_startctrl+uDelete to line start
input_backspacebackspace,shift+backspaceBackspace
input_deletectrl+d,delete,shift+deleteDelete
input_undoctrl+-,super+zUndo input
input_redoctrl+.,super+shift+zRedo input
input_word_forwardalt+f,alt+right,ctrl+rightNext word
input_word_backwardalt+b,alt+left,ctrl+leftPrevious word
input_select_word_forwardalt+shift+f,alt+shift+rightSelect next word
input_select_word_backwardalt+shift+b,alt+shift+leftSelect previous word
input_delete_word_forwardalt+d,alt+delete,ctrl+deleteDelete next word
input_delete_word_backwardctrl+w,ctrl+backspace,alt+backspaceDelete previous word

History & Terminal

Key NameDefaultDescription
history_previousupPrevious history
history_nextdownNext history
terminal_suspendctrl+zSuspend terminal
terminal_title_togglenoneToggle terminal title

Shift+Enter Configuration

Some terminals don't send Shift+Enter by default.

Windows Terminal Configuration

Edit settings.json:

json
{
  "actions": [
    {
      "command": {
        "action": "sendInput",
        "input": "\u001b[13;2u"
      },
      "id": "User.sendInput.ShiftEnterCustom"
    }
  ],
  "keybindings": [
    {
      "keys": "shift+enter",
      "id": "User.sendInput.ShiftEnterCustom"
    }
  ]
}

Quick Mnemonic

Tab switches Agents, Ctrl+C clears
Leader plus letters, functions appear
n for new, l for list, m for models
u for undo, r for redo, no worries
Arrow keys left and right, child sessions go back and forth