keybinds.mdx 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ---
  2. title: Keybinds
  3. description: Customize your keybinds.
  4. ---
  5. OpenCode has a list of keybinds that you can customize through `tui.json`.
  6. ```json title="tui.json"
  7. {
  8. "$schema": "https://opencode.ai/tui.json",
  9. "leader_timeout": 2000,
  10. "keybinds": {
  11. "leader": "ctrl+x",
  12. "app_exit": "ctrl+c,ctrl+d,<leader>q",
  13. "app_debug": "none",
  14. "app_console": "none",
  15. "app_heap_snapshot": "none",
  16. "app_toggle_animations": "none",
  17. "app_toggle_file_context": "none",
  18. "app_toggle_diffwrap": "none",
  19. "app_toggle_paste_summary": "none",
  20. "app_toggle_session_directory_filter": "none",
  21. "command_list": "ctrl+p",
  22. "help_show": "none",
  23. "docs_open": "none",
  24. "editor_open": "<leader>e",
  25. "theme_list": "<leader>t",
  26. "theme_switch_mode": "none",
  27. "theme_mode_lock": "none",
  28. "sidebar_toggle": "<leader>b",
  29. "scrollbar_toggle": "none",
  30. "status_view": "<leader>s",
  31. "session_export": "<leader>x",
  32. "session_copy": "none",
  33. "session_new": "<leader>n",
  34. "session_list": "<leader>l",
  35. "session_timeline": "<leader>g",
  36. "session_fork": "none",
  37. "session_rename": "ctrl+r",
  38. "session_delete": "ctrl+d",
  39. "session_share": "none",
  40. "session_unshare": "none",
  41. "session_interrupt": "escape",
  42. "session_compact": "<leader>c",
  43. "session_toggle_timestamps": "none",
  44. "session_toggle_generic_tool_output": "none",
  45. "session_child_first": "<leader>down",
  46. "session_child_cycle": "right",
  47. "session_child_cycle_reverse": "left",
  48. "session_parent": "up",
  49. "stash_delete": "ctrl+d",
  50. "model_provider_list": "ctrl+a",
  51. "model_favorite_toggle": "ctrl+f",
  52. "model_list": "<leader>m",
  53. "model_cycle_recent": "f2",
  54. "model_cycle_recent_reverse": "shift+f2",
  55. "model_cycle_favorite": "none",
  56. "model_cycle_favorite_reverse": "none",
  57. "mcp_list": "none",
  58. "provider_connect": "none",
  59. "console_org_switch": "none",
  60. "agent_list": "<leader>a",
  61. "agent_cycle": "tab",
  62. "agent_cycle_reverse": "shift+tab",
  63. "variant_cycle": "ctrl+t",
  64. "variant_list": "none",
  65. "messages_page_up": "pageup,ctrl+alt+b",
  66. "messages_page_down": "pagedown,ctrl+alt+f",
  67. "messages_line_up": "ctrl+alt+y",
  68. "messages_line_down": "ctrl+alt+e",
  69. "messages_half_page_up": "ctrl+alt+u",
  70. "messages_half_page_down": "ctrl+alt+d",
  71. "messages_first": "ctrl+g,home",
  72. "messages_last": "ctrl+alt+g,end",
  73. "messages_next": "none",
  74. "messages_previous": "none",
  75. "messages_last_user": "none",
  76. "messages_copy": "<leader>y",
  77. "messages_undo": "<leader>u",
  78. "messages_redo": "<leader>r",
  79. "messages_toggle_conceal": "<leader>h",
  80. "tool_details": "none",
  81. "display_thinking": "none",
  82. "prompt_submit": "none",
  83. "prompt_editor_context_clear": "none",
  84. "prompt_skills": "none",
  85. "prompt_stash": "none",
  86. "prompt_stash_pop": "none",
  87. "prompt_stash_list": "none",
  88. "workspace_set": "none",
  89. "input_clear": "ctrl+c",
  90. "input_paste": {
  91. "key": "ctrl+v",
  92. "preventDefault": false
  93. },
  94. "input_submit": "return",
  95. "input_newline": "shift+return,ctrl+return,alt+return,ctrl+j",
  96. "input_move_left": "left,ctrl+b",
  97. "input_move_right": "right,ctrl+f",
  98. "input_move_up": "up",
  99. "input_move_down": "down",
  100. "input_select_left": "shift+left",
  101. "input_select_right": "shift+right",
  102. "input_select_up": "shift+up",
  103. "input_select_down": "shift+down",
  104. "input_line_home": "ctrl+a",
  105. "input_line_end": "ctrl+e",
  106. "input_select_line_home": "ctrl+shift+a",
  107. "input_select_line_end": "ctrl+shift+e",
  108. "input_visual_line_home": "alt+a",
  109. "input_visual_line_end": "alt+e",
  110. "input_select_visual_line_home": "alt+shift+a",
  111. "input_select_visual_line_end": "alt+shift+e",
  112. "input_buffer_home": "home",
  113. "input_buffer_end": "end",
  114. "input_select_buffer_home": "shift+home",
  115. "input_select_buffer_end": "shift+end",
  116. "input_delete_line": "ctrl+shift+d",
  117. "input_delete_to_line_end": "ctrl+k",
  118. "input_delete_to_line_start": "ctrl+u",
  119. "input_backspace": "backspace,shift+backspace",
  120. "input_delete": "ctrl+d,delete,shift+delete",
  121. "input_undo": "ctrl+-,super+z",
  122. "input_redo": "ctrl+.,super+shift+z",
  123. "input_word_forward": "alt+f,alt+right,ctrl+right",
  124. "input_word_backward": "alt+b,alt+left,ctrl+left",
  125. "input_select_word_forward": "alt+shift+f,alt+shift+right",
  126. "input_select_word_backward": "alt+shift+b,alt+shift+left",
  127. "input_delete_word_forward": "alt+d,alt+delete,ctrl+delete",
  128. "input_delete_word_backward": "ctrl+w,ctrl+backspace,alt+backspace",
  129. "input_select_all": "super+a",
  130. "history_previous": "up",
  131. "history_next": "down",
  132. "dialog.select.prev": "up,ctrl+p",
  133. "dialog.select.next": "down,ctrl+n",
  134. "dialog.select.page_up": "pageup",
  135. "dialog.select.page_down": "pagedown",
  136. "dialog.select.home": "home",
  137. "dialog.select.end": "end",
  138. "dialog.select.submit": "return",
  139. "dialog.prompt.submit": "return",
  140. "dialog.mcp.toggle": "space",
  141. "prompt.autocomplete.prev": "up,ctrl+p",
  142. "prompt.autocomplete.next": "down,ctrl+n",
  143. "prompt.autocomplete.hide": "escape",
  144. "prompt.autocomplete.select": "return",
  145. "prompt.autocomplete.complete": "tab",
  146. "permission.prompt.fullscreen": "ctrl+f",
  147. "plugins.toggle": "space",
  148. "dialog.plugins.install": "shift+i",
  149. "terminal_suspend": "ctrl+z",
  150. "terminal_title_toggle": "none",
  151. "tips_toggle": "<leader>h",
  152. "plugin_manager": "none",
  153. "plugin_install": "none",
  154. "which_key_toggle": "ctrl+alt+k",
  155. "which_key_layout_toggle": "ctrl+alt+shift+k",
  156. "which_key_pending_toggle": "ctrl+alt+shift+p",
  157. "which_key_group_previous": "ctrl+alt+left,ctrl+alt+[",
  158. "which_key_group_next": "ctrl+alt+right,ctrl+alt+]",
  159. "which_key_scroll_up": "ctrl+alt+up,ctrl+alt+p",
  160. "which_key_scroll_down": "ctrl+alt+down,ctrl+alt+n",
  161. "which_key_page_up": "ctrl+alt+pageup",
  162. "which_key_page_down": "ctrl+alt+pagedown",
  163. "which_key_home": "ctrl+alt+home",
  164. "which_key_end": "ctrl+alt+end"
  165. }
  166. }
  167. ```
  168. :::note
  169. On Windows, the defaults for `input_undo` and `terminal_suspend` are different:
  170. - `input_undo` defaults to `ctrl+z,ctrl+-,super+z` when it is not explicitly configured. The `ctrl+z` binding is added because Windows terminals do not support POSIX suspend.
  171. - `terminal_suspend` is forced to `none` because native Windows terminals do not support POSIX suspend.
  172. :::
  173. ---
  174. ## Leader Key
  175. OpenCode uses a `leader` key for many keybinds. This avoids conflicts in your terminal.
  176. By default, `ctrl+x` is the leader key and many actions require you to first press the leader key and then the shortcut. For example, to start a new session you first press `ctrl+x` and then press `n`.
  177. You don't need to use a leader key for your keybinds but we recommend doing so.
  178. Some navigation keybinds intentionally do not use the leader key by default. For subagent sessions, the defaults are `session_child_first` = `<leader>down`, `session_child_cycle` = `right`, `session_child_cycle_reverse` = `left`, and `session_parent` = `up`.
  179. `leader_timeout` controls how long OpenCode waits for the next key after the leader key. It defaults to `2000` milliseconds.
  180. ---
  181. ## Binding Values
  182. A string can contain one shortcut or multiple comma-separated shortcuts. You can also use an array for multiple shortcuts.
  183. For advanced cases, use an object with `key`, `event`, `preventDefault`, or `fallthrough`.
  184. ```json title="tui.json"
  185. {
  186. "$schema": "https://opencode.ai/tui.json",
  187. "keybinds": {
  188. "messages_copy": ["<leader>y", "ctrl+shift+c"],
  189. "input_paste": {
  190. "key": "ctrl+v",
  191. "preventDefault": false
  192. }
  193. }
  194. }
  195. ```
  196. ---
  197. ## Disable Keybind
  198. You can disable a keybind by adding the key to `tui.json` with a value of `"none"` or `false`.
  199. ```json title="tui.json"
  200. {
  201. "$schema": "https://opencode.ai/tui.json",
  202. "keybinds": {
  203. "session_compact": "none"
  204. }
  205. }
  206. ```
  207. ---
  208. ## Desktop Prompt Shortcuts
  209. The OpenCode desktop app prompt input supports common Readline/Emacs-style shortcuts for editing text. These are built-in and currently not configurable via `opencode.json`.
  210. | Shortcut | Action |
  211. | -------- | ---------------------------------------- |
  212. | `ctrl+a` | Move to start of current line |
  213. | `ctrl+e` | Move to end of current line |
  214. | `ctrl+b` | Move cursor back one character |
  215. | `ctrl+f` | Move cursor forward one character |
  216. | `alt+b` | Move cursor back one word |
  217. | `alt+f` | Move cursor forward one word |
  218. | `ctrl+d` | Delete character under cursor |
  219. | `ctrl+k` | Kill to end of line |
  220. | `ctrl+u` | Kill to start of line |
  221. | `ctrl+w` | Kill previous word |
  222. | `alt+d` | Kill next word |
  223. | `ctrl+t` | Transpose characters |
  224. | `ctrl+g` | Cancel popovers / abort running response |
  225. ---
  226. ## Shift+Enter
  227. 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.
  228. ### Windows Terminal
  229. Open your `settings.json` at:
  230. ```
  231. %LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
  232. ```
  233. Add this to the root-level `actions` array:
  234. ```json
  235. "actions": [
  236. {
  237. "command": {
  238. "action": "sendInput",
  239. "input": "\u001b[13;2u"
  240. },
  241. "id": "User.sendInput.ShiftEnterCustom"
  242. }
  243. ]
  244. ```
  245. Add this to the root-level `keybindings` array:
  246. ```json
  247. "keybindings": [
  248. {
  249. "keys": "shift+enter",
  250. "id": "User.sendInput.ShiftEnterCustom"
  251. }
  252. ]
  253. ```
  254. Save the file and restart Windows Terminal or open a new tab.