OpenCode Keyboard Shortcut Configuration Explained

OpenCode provides a complete keyboard shortcut system, covering various operations such as application control, session management, message browsing, model switching, and input editing.

All keyboard shortcuts can be customized through thetui.jsonfile.


Configuration File

Keyboard shortcut configurations are written under thetui.jsonfield of thekeybindsfile. The key name of each record is the operation name, and the value is the corresponding keyboard shortcut:

Example

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
"leader": "ctrl+x", // Leader key setting (see explanation below)
"session_new": "<leader>n", // New session: press the leader key, then press n
"model_list": "<leader>m", // Open model list: press the leader key, then press m
"session_compact": "none" // Set the value to "none" to disable this shortcut
  }
}

An operation can be bound to multiple keyboard shortcuts, separated by commas. Triggering any one of them will execute the operation:

Example

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
// The following notation means: pressing pageup or ctrl+alt+b will scroll up one page
    "messages_page_up": "pageup,ctrl+alt+b"
  }
}

Leader Key

Most of OpenCode's keyboard shortcuts use theLeader Keymechanism: press the leader key first, then the function key, and the combination of the two keys triggers the corresponding operation. The benefit of this design is to avoid conflicts with the terminal's own keyboard shortcuts.

The default leader key isctrl+x. For example, the shortcut for creating a new session is<leader>n, and the actual operation is: first pressctrl+x, then pressn。

You can change the leader key to any key combination:

Example

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
"leader": "ctrl+x" // Change the leader key to another key, such as "ctrl+space", "alt+x", etc.
// The <leader> placeholder in the configuration will be automatically replaced with the key set here
  }
}

You don't have to use the leader key mechanism to set keyboard shortcuts — you can also directly bind normal keys or key combinations. However, it is recommended to prefer the leader key to avoid conflicts with terminal shortcuts.


Disabling Keyboard Shortcuts

Set the value of any keyboard shortcut to"none"to disable that operation. After disabling, pressing any key will not trigger it:

Example

{
  "$schema": "https://opencode.ai/tui.json",
  "keybinds": {
"session_compact": "none", // Disable the "compact session" shortcut
"scrollbar_toggle": "none", // Disable the "toggle scrollbar" shortcut
"tips_toggle": "none" // Disable the "toggle tips" shortcut
  }
}

Complete Keyboard Shortcut List

1. Application & Interface

Operation Name Default Shortcut Description
app_exit ctrl+c, ctrl+d, <leader>q Exit OpenCode
editor_open <leader>e Open current input content with an external editor
theme_list <leader>t Open the theme list and switch the interface theme
sidebar_toggle <leader>b Show or hide the sidebar
scrollbar_toggle None (disabled by default) Show or hide the scrollbar
username_toggle None (disabled by default) Show or hide the username
status_view <leader>s View current status information
tool_details None (disabled by default) View tool call details
command_list ctrl+p Open the command palette and search all available commands
tips_toggle <leader>h Show or hide usage tips
display_thinking None (disabled by default) Show or hide the model's thinking process
terminal_suspend ctrl+z Suspend the terminal (put OpenCode in the background and return to the shell; typefgto resume)
terminal_title_toggle None (disabled by default) Show or hide the terminal title bar

2. Session Management

Operation Name Default Shortcut Description
session_new <leader>n Create a new session
session_list <leader>l View all historical session lists
session_export <leader>x Export current session content
session_timeline <leader>g View the timeline of the current session
session_fork None (disabled by default) Create a branch session from the current position
session_rename None (disabled by default) Rename the current session
session_share None (disabled by default) Share the current session
session_unshare None (disabled by default) Cancel sharing the current session
session_interrupt escape Interrupt the currently running response
session_compact <leader>c Compact the current session context to reduce token usage
session_child_first <leader>↓ Jump to the first child session
session_child_cycle <leader>→ Cycle forward through child sessions
session_child_cycle_reverse <leader>← Cycle backward through child sessions
session_parent <leader>↑ Return to the parent session

3. Message Navigation

Operation Name Default Shortcut Description
messages_page_up pageup, ctrl+alt+b Scroll up one page of messages
messages_page_down pagedown, ctrl+alt+f Scroll down one page of messages
messages_line_up ctrl+alt+y Scroll up one line
messages_line_down ctrl+alt+e Scroll down one line
messages_half_page_up ctrl+alt+u Scroll up half a page
messages_half_page_down ctrl+alt+d Scroll down half a page
messages_first ctrl+g, home Jump to the earliest first message
messages_last ctrl+alt+g, end Jump to the latest last message
messages_next None (disabled by default) Jump to the next message
messages_previous None (disabled by default) Jump to the previous message
messages_last_user None (disabled by default) Jump to the last user message
messages_copy <leader>y Copy current message content to the clipboard
messages_undo <leader>u Undo the last operation
messages_redo <leader>r Redo the undone operation
messages_toggle_conceal <leader>h Collapse or expand hidden content in messages

4. Models & Agents

Operation Name Default Shortcut Description
model_list <leader>m Open the model list to select and switch the currently used model
model_cycle_recent f2 Cycle forward through recently used models
model_cycle_recent_reverse shift+f2 Cycle backward through recently used models
model_cycle_favorite None (disabled by default) Cycle forward through favorite models
model_cycle_favorite_reverse None (disabled by default) Cycle backward through favorite models
variant_cycle ctrl+t Cycle through variants of the current model (such as thinking mode)
agent_list <leader>a Open the agent list to select and switch the currently used agent
agent_cycle tab Cycle forward through agents
agent_cycle_reverse shift+tab Cycle backward through agents

5. Input Box Editing

Operation Name Default Shortcut Description
input_submit return Send current input content
input_newline shift+return, ctrl+return, alt+return, ctrl+j Insert a line break in the input box (without sending)
input_clear ctrl+c Clear the input box content
input_paste ctrl+v Paste clipboard content into the input box
input_move_left left, ctrl+b Move the cursor left by one character
input_move_right right, ctrl+f Move the cursor right by one character
input_move_up up Move the cursor up one line
input_move_down down Move the cursor down one line
input_word_forward alt+f, alt+right, ctrl+right Move the cursor forward by one word
input_word_backward alt+b, alt+left, ctrl+left Move the cursor backward by one word
input_line_home ctrl+a Move to the beginning of the current line
input_line_end ctrl+e Move to the end of the current line
input_visual_line_home alt+a Move to the beginning of the current visual line (the line as displayed after wrapping)
input_visual_line_end alt+e Move to the end of the current visual line
input_buffer_home home Jump to the very beginning of the entire input box content
input_buffer_end end Jump to the very end of the entire input box content
input_delete_to_line_end ctrl+k Delete all content from the cursor to the end of the current line
input_delete_to_line_start ctrl+u Delete all content from the beginning of the current line to the cursor
input_delete_line ctrl+shift+d Delete the entire line where the cursor is located
input_backspace backspace, shift+backspace Delete the character before the cursor
input_delete ctrl+d, delete, shift+delete Delete the character after the cursor
input_delete_word_forward alt+d, alt+delete, ctrl+delete Delete the word after the cursor
input_delete_word_backward ctrl+w, ctrl+backspace, alt+backspace Delete the word before the cursor
input_undo ctrl+-, super+z Undo the last edit in the input box
input_redo ctrl+., super+shift+z Redo the undone edit

6. Text Selection

Operation Name Default Shortcut Description
input_select_left shift+left Select one character to the left
input_select_right shift+right Select one character to the right
input_select_up shift+up Select one line upward
input_select_down shift+down Select one line downward
input_select_word_forward alt+shift+f, alt+shift+right Select one word forward
input_select_word_backward alt+shift+b, alt+shift+left Select one word backward
input_select_line_home ctrl+shift+a Select from the cursor position to the beginning of the current line
input_select_line_end ctrl+shift+e Select from the cursor position to the end of the current line
input_select_visual_line_home alt+shift+a Select from the cursor position to the beginning of the current visual line
input_select_visual_line_end alt+shift+e Select from the cursor position to the end of the current visual line
input_select_buffer_home shift+home Select from the cursor position to the very beginning of the input box
input_select_buffer_end shift+end Select from the cursor position to the very end of the input box

7. Input History

Operation Name Default Shortcut Description
history_previous up Retrieve the previous history input (works when the input box is empty)
history_next down Retrieve the next history input

Desktop Version Built-in Input Shortcuts

The prompt input box in the OpenCode desktop version additionally has a built-in set ofReadline / Emacs styletext editing shortcuts,These shortcuts are built-in features and cannot betui.jsonchanged by modifying or disabling:

shortcuts. Operation
ctrl+a Move to the beginning of the current line
ctrl+e Move to the end of the current line
ctrl+b Move the cursor backward one character
ctrl+f Move the cursor forward one character
alt+b Move the cursor backward one word
alt+f Move the cursor forward one word
ctrl+d Delete the character at the cursor position
ctrl+k Delete the content from the cursor to the end of the line
ctrl+u Delete the content from the cursor to the beginning of the line
ctrl+w Delete the previous word
alt+d Delete the next word
ctrl+t Swap the positions of the two characters before and after the cursor
ctrl+g Cancel the current popup window, or abort the ongoing response

Configuring Shift+Enter for Line Breaks

Some terminals by default do not send Enter with modifier keys (e.g.Shift+Enter) as a separate key press, causing pressing it in OpenCode toShift+Enternot create a new line but instead directly send the message.

Windows Terminal Configuration Method

Step 1:Open Windows Terminal'ssettings.jsonfile, the path is:

%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

Step 2:In the root-levelactionsarray of the file, add the following configuration to define aShift+Enteraction that sends an escape sequence:

Example

"actions": [
  {
    "command": {
      "action": "sendInput",
"input": "\u001b[13;2u" // Standard escape sequence for Shift+Enter (CSI u format)
    },
    "id": "User.sendInput.ShiftEnterCustom"
  }
]

Step 3:In the root-levelkeybindingsarray of the file, add a key binding to mapShift+Enterto the action defined above:

Example

"keybindings": [
  {
    "keys": "shift+enter",
    "id": "User.sendInput.ShiftEnterCustom"
  }
]

Step 4:Savesettings.jsonAfter saving the file, restart Windows Terminal or open a new tab for the configuration to take effect.

If you are using other terminals (such as iTerm2, Kitty, Alacritty, etc.), refer to the corresponding terminal's documentation, find the "Key Mappings" or "Key bindings" related settings, and setShift+Enterit to send\u001b[13;2uthe escape sequence.

Other Extensions