Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

keybindings.md

81 lines3.0 KB

1# Keybindings
2​
3Customize shortcuts in **Settings → Keybindings** on web and desktop. That page
4also lists the command IDs and defaults available in your version.
5​
6## Edit the configuration file
7​
8Keybindings live on the environment's machine, in
9`~/.t3/userdata/keybindings.json` by default. You can edit this file directly.
10It is a JSON array of rules:
11​
12```json
14 { "key": "mod+g", "command": "terminal.toggle" },
15 { "key": "mod+shift+g", "command": "terminal.new", "when": "terminalFocus" }
17```
18​
19T3 Code creates the file with its defaults and adds new defaults on later startups.
20New defaults do not replace commands you customized. If a new default overlaps one
21of your shortcuts, [rule order](#precedence) decides which runs.
22Invalid rules are ignored; if the file cannot be parsed, T3 Code uses defaults.
23​
24## Rule shape
25​
26Each rule requires a `key` shortcut and a `command` ID. An optional `when`
27expression restricts when it runs.
28​
29Project scripts use `script.{id}.run`, such as `script.test.run`.
30​
31## Key syntax
32​
33Join modifiers and a key with `+`, such as `mod+shift+d` or `ctrl+l`.
34`mod` means Command on macOS and Control elsewhere. Other modifiers are
35`cmd` / `meta`, `ctrl` / `control`, `alt` / `option`, and `shift`.
36​
37## When conditions
38​
39Available context keys are `terminalFocus`, `terminalOpen`, `previewFocus`,
40`previewOpen`, and `modelPickerOpen`. Unknown keys evaluate to `false`.
41​
42Combine keys with `!` for not, `&&` for and, `||` for or, and parentheses:
43​
44```json
45{ "key": "mod+j", "command": "terminal.toggle", "when": "terminalOpen && !terminalFocus" }
46```
47​
48## Precedence
49​
50The last rule whose key and condition both match wins, even if it belongs to a
51different command. Put a more specific rule after a general one when they share
52a shortcut.
53​
54## Commands with special behavior
55​
56`thread.stop` interrupts the running turn in the focused thread. It has no default
57shortcut; assign one in **Settings → Keybindings**.
58​
59`chat.new` may ask you to choose a project when there is more than one.
60`chat.newLocal` skips that chooser. Both use your
61[new-thread defaults](./thread-sidebar.md#start-a-thread).
62​
63## Reserved shortcuts
64​
65In the desktop app, `mod+w` closes the focused terminal or the active right-panel
66tab. When nothing remains to close, it closes the window. In a browser, `mod+w`
67closes the browser tab; rebind `rightPanel.close` and `terminal.close` to an available
68shortcut such as `alt+w`.
69​
70Many defaults include `!terminalFocus` so they do not intercept terminal input.
71Keep that condition when remapping them if you want the same behavior.
72​
73## Desktop quit shortcut
74​
75Use `Cmd+Q` on macOS or `Ctrl+Q` on Windows and Linux. In the default **Hold** mode,
76hold for 1.2 seconds or press twice within 500 milliseconds. Holding requires
77keyboard repeat; if repeat is disabled, use two presses or the application menu.
78​
79Change **Settings → General → Confirmations → Quit shortcut** to **Direct** for a
80single press or **Double press** for two presses only. Choosing **Quit** from the
81application menu always quits immediately.