Skip to content

5.6b Keybindings

60+ fully customizable keybindings for a smooth operational experience.

📝 Course Notes

Key concepts from this lesson:

Keybindings Notes

What You'll Learn

  • Master the Leader key mechanism
  • Customize any keybinding
  • Disable unwanted keybindings
  • Resolve terminal keybinding conflicts

Leader Key

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

Default Leader key: Ctrl+X

Usage: Press Leader key, release, then press the second key.

Ctrl+X → n    # New session
Ctrl+X → l    # Session list
Ctrl+X → m    # Model list

Keybinding Configuration

Configure in opencode.json:

jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "keybinds": {
    // Change Leader key
    "leader": "ctrl+x",
    
    // Custom keybindings
    "session_new": "<leader>n",
    "model_list": "<leader>m",
    
    // Multiple keys for same function (comma-separated)
    "app_exit": "ctrl+c,ctrl+d,<leader>q",
    
    // Disable keybinding
    "session_compact": "none"
  }
}

Note: The config key is keybinds (plural), this is the only config key that uses plural form!

Disable Keybindings

Set to "none" to disable:

jsonc
{
  "keybinds": {
    "session_compact": "none",
    "sidebar_toggle": "none"
  }
}

Multiple Key Bindings

Use commas to separate multiple keys:

jsonc
{
  "keybinds": {
    "input_newline": "shift+return,ctrl+return,alt+return,ctrl+j"
  }
}

Complete Keybinding List

Application Control

Key NameDefaultDescription
leaderctrl+xLeader key
app_exitctrl+c,ctrl+d,<leader>qExit application
terminal_suspendctrl+zSuspend terminal
terminal_title_togglenoneToggle terminal title

Interface Control

Key NameDefaultDescription
editor_open<leader>eOpen external editor
theme_list<leader>tTheme list
sidebar_toggle<leader>bToggle sidebar
scrollbar_togglenoneToggle scrollbar
username_togglenoneToggle username display
status_view<leader>sStatus view
tool_detailsnoneToggle tool details
tips_toggle<leader>hToggle homepage tips

Session Management

Key NameDefaultDescription
session_new<leader>nNew session
session_list<leader>lSession list
session_export<leader>xExport session
session_timeline<leader>gSession timeline
session_interruptescapeInterrupt response
session_compact<leader>cCompact context
session_forknoneFork from message
session_renamenoneRename session
session_sharenoneShare session
session_unsharenoneUnshare session

Session Navigation

Key NameDefaultDescription
session_child_cycle<leader>rightCycle child sessions
session_child_cycle_reverse<leader>leftCycle child sessions (reverse)
session_parent<leader>upReturn to parent session

Message Operations

Key NameDefaultDescription
messages_copy<leader>yCopy message
messages_undo<leader>uUndo message
messages_redo<leader>rRedo message
messages_toggle_conceal<leader>hToggle code block folding

Message Scrolling

Key NameDefaultDescription
messages_page_uppageupPage up
messages_page_downpagedownPage down
messages_half_page_upctrl+alt+uHalf page up
messages_half_page_downctrl+alt+dHalf page down
messages_firstctrl+g,homeJump to first
messages_lastctrl+alt+g,endJump to last
messages_nextnoneNext message
messages_previousnonePrevious message
messages_last_usernoneLast user message

Model & Agent

Key NameDefaultDescription
model_list<leader>mModel list
model_cycle_recentf2Cycle recent models
model_cycle_recent_reverseshift+f2Cycle recent (reverse)
model_cycle_favoritenoneCycle favorite models
model_cycle_favorite_reversenoneCycle favorites (reverse)
variant_cyclectrl+tCycle model variants
agent_list<leader>aAgent list
agent_cycletabCycle Agent
agent_cycle_reverseshift+tabCycle Agent (reverse)
command_listctrl+pCommand palette

Input Area Basics

Key NameDefaultDescription
input_submitreturnSend message
input_newlineshift+return,ctrl+return,alt+return,ctrl+jNew line
input_clearctrl+cClear input
input_pastectrl+vPaste
input_undoctrl+-,super+zUndo input
input_redoctrl+.,super+shift+zRedo input

Input Area Cursor Movement

Key NameDefaultDescription
input_move_leftleft,ctrl+bMove left one character
input_move_rightright,ctrl+fMove right one character
input_move_upupMove up one line
input_move_downdownMove down one line
input_word_forwardalt+f,alt+right,ctrl+rightMove forward one word
input_word_backwardalt+b,alt+left,ctrl+leftMove backward one word
input_line_homectrl+aMove to line start
input_line_endctrl+eMove to line end
input_visual_line_homealt+aMove to visual line start
input_visual_line_endalt+eMove to visual line end
input_buffer_homehomeMove to buffer start
input_buffer_endendMove to buffer end

Input Area Selection

Key NameDefaultDescription
input_select_leftshift+leftSelect left
input_select_rightshift+rightSelect right
input_select_upshift+upSelect up
input_select_downshift+downSelect down
input_select_word_forwardalt+shift+f,alt+shift+rightSelect next word
input_select_word_backwardalt+shift+b,alt+shift+leftSelect previous word
input_select_line_homectrl+shift+aSelect to line start
input_select_line_endctrl+shift+eSelect to 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_select_buffer_homeshift+homeSelect to buffer start
input_select_buffer_endshift+endSelect to buffer end

Input Area Deletion

Key NameDefaultDescription
input_backspacebackspace,shift+backspaceBackspace
input_deletectrl+d,delete,shift+deleteDelete character
input_delete_linectrl+shift+dDelete entire line
input_delete_to_line_endctrl+kDelete to line end
input_delete_to_line_startctrl+uDelete to line start
input_delete_word_forwardalt+d,alt+delete,ctrl+deleteDelete next word
input_delete_word_backwardctrl+w,ctrl+backspace,alt+backspaceDelete previous word

History

Key NameDefaultDescription
history_previousupPrevious history
history_nextdownNext history

Desktop Version Keybindings

OpenCode Desktop's input field supports Readline/Emacs style keybindings (built-in, not configurable):

KeybindingFunction
Ctrl+AMove to line start
Ctrl+EMove to line end
Ctrl+BMove back one character
Ctrl+FMove forward one character
Alt+BMove back one word
Alt+FMove forward one word
Ctrl+DDelete current character
Ctrl+KDelete to line end
Ctrl+UDelete to line start
Ctrl+WDelete previous word
Alt+DDelete next word
Ctrl+TTranspose characters
Ctrl+GCancel popup / Interrupt response

Terminal Compatibility

Shift+Enter Issue

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

Symptom: Pressing Shift+Enter sends the message instead of creating a new line.

Windows Terminal Configuration

Edit settings.json (path: %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json):

Add to the actions array:

json
{
  "command": {
    "action": "sendInput",
    "input": "\u001b[13;2u"
  },
  "id": "User.sendInput.ShiftEnterCustom"
}

Add to the keybindings array:

json
{
  "keys": "shift+enter",
  "id": "User.sendInput.ShiftEnterCustom"
}

Save and restart Windows Terminal.

Other Terminals

  • iTerm2: Supported by default, no configuration needed
  • Alacritty: Supported by default
  • Kitty: Supported by default
  • GNOME Terminal: May need to update to a newer version

Common Configuration Scenarios

Vim Style

jsonc
{
  "keybinds": {
    "leader": "space",
    "messages_page_up": "ctrl+u",
    "messages_page_down": "ctrl+d",
    "messages_first": "gg",
    "messages_last": "G"
  }
}

Minimal Mode

Disable uncommon keybindings:

jsonc
{
  "keybinds": {
    "sidebar_toggle": "none",
    "scrollbar_toggle": "none",
    "session_fork": "none",
    "session_share": "none",
    "session_unshare": "none",
    "tips_toggle": "none"
  }
}

One-Handed Operation

Concentrate common operations on the left hand:

jsonc
{
  "keybinds": {
    "session_new": "ctrl+n",
    "session_list": "ctrl+l",
    "model_list": "ctrl+m",
    "agent_cycle": "ctrl+tab"
  }
}

Troubleshooting

SymptomCauseSolution
Keybinding not workingTerminal intercepted the keyCheck terminal settings or use a different key
Shift+Enter doesn't create new lineTerminal doesn't send modifier keyConfigure terminal (see above)
Configured but no responseUsed keybind (singular)Use keybinds (plural)
Using null to disable doesn't workSyntax errorUse "none" string instead
Leader key conflictConflicts with other programsUse a different Leader key like ctrl+space
Ctrl+C doesn't clear inputIntercepted by terminal's SIGINTUse a different key or accept default behavior

Keybinding Mnemonic

Tab cycles Agent, Ctrl+C clears
Leader plus letter, any function appears
n for new, l for list, m for model
u for undo, r for redo, no need to huddle
Arrow keys left and right, child sessions take flight

Lesson Summary

You learned:

  1. Using the Leader key mechanism to avoid conflicts
  2. Customizing keybindings in keybinds
  3. Using "none" to disable unwanted keybindings
  4. Using commas to bind multiple keys
  5. Resolving terminal Shift+Enter compatibility issues