OpenCode Keybinds Configuration
Customize keyboard shortcuts in OpenCode's Terminal User Interface (TUI) and desktop application.
Overview
OpenCode allows you to customize keybinds through the tui.json configuration file. You can modify existing shortcuts, disable unwanted ones, and create custom keybindings to match your workflow preferences.
Keybinds Configuration File
Keybinds are configured in tui.json with the following structure:
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"leader": "ctrl+x",
"app_exit": "ctrl+c,ctrl+d,<leader>q",
// ... other keybinds
}
}
Important Concepts
Leader Key
OpenCode uses a leader key for most keybinds to avoid conflicts with terminal shortcuts. By default, ctrl+x is the leader key. Most actions require pressing the leader key first, then the shortcut. For example, to start a new session, press ctrl+x then n.
You can customize the leader key or choose not to use one, though using a leader key is recommended.
Disabling Keybinds
You can disable any keybind by setting its value to "none" in the configuration:
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"session_compact": "none"
}
}
Desktop Prompt Shortcuts
The OpenCode desktop app prompt input supports common Readline/Emacs-style shortcuts that are built-in and not configurable via tui.json:
| Shortcut | Action |
|---|---|
ctrl+a |
Move to start of current line |
ctrl+e |
Move to end of current line |
ctrl+b |
Move cursor back one character |
ctrl+f |
Move cursor forward one character |
alt+b |
Move cursor back one word |
alt+f |
Move cursor forward one word |
ctrl+d |
Delete character under cursor |
ctrl+k |
Kill to end of line |
ctrl+u |
Kill to start of line |
ctrl+w |
Kill previous word |
alt+d |
Kill next word |
ctrl+t |
Transpose characters |
ctrl+g |
Cancel popovers / abort running response |
Shift+Enter Configuration
Some terminals don't send modifier keys with Enter by default. You may need to configure your terminal to send Shift+Enter as an escape sequence.
Windows Terminal Configuration
To configure Shift+Enter in Windows Terminal:
Open your
settings.jsonat:%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.jsonAdd this to the root-level
actionsarray:"actions": [ { "command": { "action": "sendInput", "input": "\u001b[13;2u" }, "id": "User.sendInput.ShiftEnterCustom" } ]Add this to the root-level
keybindingsarray:"keybindings": [ { "keys": "shift+enter", "id": "User.sendInput.ShiftEnterCustom" } ]Save the file and restart Windows Terminal or open a new tab.
Common Keybind Categories
Session Management
session_new- Create a new sessionsession_list- List sessionssession_timeline- View session timelinesession_fork- Fork a sessionsession_rename- Rename a sessionsession_share/session_unshare- Share/unshare sessionssession_interrupt- Interrupt current sessionsession_compact- Compact session viewsession_child_first/session_child_cycle/session_child_cycle_reverse/session_parent- Navigate between parent/child sessions
Message Navigation
messages_page_up/messages_page_down- Page through messagesmessages_line_up/messages_line_down- Move line by linemessages_half_page_up/messages_half_page_down- Half-page movementmessages_first/messages_last- Go to first/last messagemessages_next/messages_previous- Navigate between messagesmessages_copy- Copy selected messagemessages_undo/messages_redo/messages_last_user- Undo/redo actionsmessages_toggle_conceal- Toggle message concealment
Model Management
model_list- List available modelsmodel_cycle_recent/model_cycle_recent_reverse- Cycle through recent modelsmodel_cycle_favorite/model_cycle_favorite_reverse- Cycle through favorite models
Agent Management
agent_list- List available agentsagent_cycle/agent_cycle_reverse- Cycle through agents
Input Editing
input_clear- Clear inputinput_paste- Paste into inputinput_submit- Submit input (Enter/Return)input_newline- Add newline (Shift+Enter, Ctrl+Enter, Alt+Enter, Ctrl+J)- Movement:
input_move_left/right/up/down - Selection:
input_select_left/right/up/down - Home/End:
input_line_home/end,input_select_line_home/end - Visual selection:
input_visual_line_home/end,input_select_visual_line_home/end - Buffer navigation:
input_select_buffer_home/end - Deletion:
input_delete_line,input_delete_to_line_end/start,input_backspace,input_delete - Undo/Redo:
input_undo,input_redo - Word navigation:
input_word_forward/backward,input_select_word_forward/backward - Word deletion:
input_delete_word_forward/backward
History Navigation
history_previous/history_next- Navigate command history
Terminal & Misc
terminal_suspend- Suspend terminal (Ctrl+Z)terminal_title_toggle- Toggle terminal titletips_toggle- Show/hide tipsdisplay_thinking- Display thinking process
Best Practices
- Start with Defaults: Begin with OpenCode's default keybinds and customize only what doesn't work for you
- Consider Conflicts: Avoid keybinds that conflict with your terminal, shell, or other frequently used applications
- Leader Key Usage: Use the leader key for most customizations to prevent conflicts
- Group Related Actions: Keep related functions on similar key combinations for muscle memory
- Accessibility: Consider physical comfort when choosing key combinations
- Document Changes: Keep track of your custom keybinds for reference and team sharing
- Test Thoroughly: Verify that your keybinds work as expected in different contexts
Example Configurations
Custom Leader Key
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"leader": "ctrl+\\",
"app_exit": "ctrl+c,ctrl+d,<leader>q",
"editor_open": "<leader>e"
}
}
Vim-like Navigation
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"messages_line_up": "k",
"messages_line_down": "j",
"messages_half_page_up": "ctrl+u",
"messages_half_page_down": "ctrl+d",
"messages_first": "g",
"messages_last": "G",
"session_child_first": "<leader>j",
"session_child_cycle": "l",
"session_child_cycle_reverse": "h",
"session_parent": "k"
}
}
Emacs-inspired
{
"$schema": "https://opencode.ai/tui.json",
"keybinds": {
"input_clear": "ctrl+g",
"input_move_left": "ctrl+b",
"input_move_right": "ctrl+f",
"input_move_up": "ctrl+p",
"input_move_down": "ctrl+n",
"input_select_left": "meta+b",
"input_select_right": "meta+f",
"input_select_up": "meta+p",
"input_select_down": "meta+n",
"input_line_home": "ctrl+a",
"input_line_end": "ctrl+e"
}
}
By customizing keybinds, you can make OpenCode feel more natural and efficient for your specific workflow and editing preferences.