2021-02-20 19:38:46 +03:00
Keyboard bindings are configurable.
2020-05-22 18:05:59 +03:00
2021-02-20 19:38:46 +03:00
The assignments are based around a triggering keypress which may be combined
with a set of modifier keys to produce an action.
2020-05-22 18:05:59 +03:00
2020-06-20 23:37:59 +03:00
## Alt / Option Key Behavior & Composed Keys
The operating system has its own user selectable keymap that is sometimes at
odds with old-school terminal emulation that pre-dates internationalization as
a concept. WezTerm tries to behave reasonably by default, but also give you
control in other situations.
### Layouts with an AltGr key
If you have, for example, a European keyboard layout with an AltGr key then
wezterm will respect the composition effects of AltGr produced by the system.
For example, in a German keymap, `AltGr <` will produce `|` .
If your physical keyboard doesn't match the keyboard layout (eg: using a US
keyboard with DEU selected in the OS), then the right hand `Alt` key is often
re-interpreted as having the `AltGr` function with behavior as described above.
The left `Alt` will be treated as a modifier with no composition effects.
### macOS Left and Right Option Key
2020-06-21 02:07:21 +03:00
*since: 20200620-160318-e00b076c*
2020-06-20 23:37:59 +03:00
The default behavior is to treat the left `Option` key as the `Alt` modifier
with no composition effects, while the right `Option` key performs composition
(making it approximately equivalent to `AltGr` on other operating systems).
You can control this behavior in your configuration:
```lua
return {
send_composed_key_when_left_alt_is_pressed=false,
send_composed_key_when_right_alt_is_pressed=true,
}
```
If you're running an earlier release the options were a bit more limited;
both left and right `Option` keys behave identically and composition
behavior was influenced for both of them via the `send_composed_key_when_alt_is_pressed`
configuration option.
2021-02-03 21:03:04 +03:00
*since: 20210203-095643-70a364eb*
2021-02-01 04:06:30 +03:00
WezTerm is now able to perform dead-key expansion when `use_ime = false` . Dead
keys are treated as composition effects, so with the default settings of
`send_composed_key_when_left_alt_is_pressed` and
`send_composed_key_when_right_alt_is_pressed` above, in a US layout, `Left-Opt
n` will produce `Alt N` and `Right-Opt n` will will for a subsequent key press
2021-02-01 04:32:11 +03:00
before generating an event; `Right-Opt n SPACE` will emit `~` whereas `Right-Opt n
2021-02-01 04:06:30 +03:00
n` will emit `ñ` .
2021-02-01 04:32:11 +03:00
You may also set `use_dead_keys = false` to skip the hold state; continuing
the example above, `Right-Opt n` will then immediately produce `~` .
2021-10-03 18:46:13 +03:00
### Input Method Editor (IME)
2020-06-20 23:37:59 +03:00
2020-10-19 00:07:23 +03:00
WezTerm has support for using the operating system Input Method Editor (IME) on
2021-10-03 18:46:13 +03:00
some operating systems.
2020-06-20 23:37:59 +03:00
2021-10-03 18:46:13 +03:00
[The `use_ime` docs have more information ](lua/config/use_ime.md ).
2020-06-20 23:37:59 +03:00
2020-10-16 22:13:30 +03:00
### Microsoft Windows and Dead Keys
2020-11-01 01:51:08 +03:00
*since: 20201031-154415-9614e117*
2020-10-16 22:13:30 +03:00
By default, if you are using a layout with *dead keys* (eg: US International
layout, or a number of European layouts such as German or French) pressing
a dead key in wezterm will "hold" the dead key until the next character is
pressed, resulting in a combined character with a diacritic. For example,
pressing `^` and then `e` will produce `ê` . Pressing `^` then `SPACE`
will produce `^` on its own.
If you are a heavy user of Vi style editors then you may wish to disable
dead key processing so that `^` can be used with a single keypress.
You can tell WezTerm to disable dead keys by setting this in your configuration
file:
```lua
return {
use_dead_keys = false
}
```
2021-03-07 17:51:01 +03:00
### Microsoft Windows and Ctrl-Alt <-> AltGr
2021-03-07 22:21:29 +03:00
If you are using VNC and a keyboard layout with dead keys, then you may wish to enable [treat_left_ctrlalt_as_altgr ](lua/config/treat_left_ctrlalt_as_altgr.md ).
2021-03-07 17:51:01 +03:00
2020-06-20 23:37:59 +03:00
### Defining Assignments for key combinations that may be composed
When a key combination produces a composed key result, wezterm will look up
both the composed and uncomposed versions of the keypress in your key mappings.
If either lookup matches your assignment, that will take precedence over
the normal key processing.
## Default Shortcut / Key Binding Assignments
2019-12-30 07:41:08 +03:00
The default key bindings are:
| Modifiers | Key | Action |
| --------- | --- | ------ |
2021-01-31 20:28:42 +03:00
| `SUPER` | `c` | `CopyTo="Clipboard"` |
| `SUPER` | `v` | `PasteFrom="Clipboard"` |
| `CTRL+SHIFT` | `c` | `CopyTo="Clipboard"` |
| `CTRL+SHIFT` | `v` | `PasteFrom="Clipboard"` |
2021-02-03 21:03:04 +03:00
| `CTRL` | `Insert` | `CopyTo="PrimarySelection"` (*since: 20210203-095643-70a364eb*) |
2021-01-31 20:28:42 +03:00
| `SHIFT` | `Insert` | `PasteFrom="PrimarySelection"` |
2019-12-30 07:41:08 +03:00
| `SUPER` | `m` | `Hide` |
| `SUPER` | `n` | `SpawnWindow` |
| `CTRL+SHIFT` | `n` | `SpawnWindow` |
| `ALT` | `Enter` | `ToggleFullScreen` |
| `SUPER` | `-` | `DecreaseFontSize` |
| `CTRL` | `-` | `DecreaseFontSize` |
| `SUPER` | `=` | `IncreaseFontSize` |
| `CTRL` | `=` | `IncreaseFontSize` |
| `SUPER` | `0` | `ResetFontSize` |
| `CTRL` | `0` | `ResetFontSize` |
2020-06-27 02:49:07 +03:00
| `SUPER` | `t` | `SpawnTab="CurrentPaneDomain"` |
| `CTRL+SHIFT` | `t` | `SpawnTab="CurrentPaneDomain"` |
2020-05-22 09:09:57 +03:00
| `SUPER+SHIFT` | `T` | `SpawnTab="DefaultDomain"` |
2020-12-26 09:43:58 +03:00
| `SUPER` | `w` | `CloseCurrentTab{confirm=true}` |
2020-05-22 09:09:57 +03:00
| `SUPER` | `1` | `ActivateTab=0` |
| `SUPER` | `2` | `ActivateTab=1` |
| `SUPER` | `3` | `ActivateTab=2` |
| `SUPER` | `4` | `ActivateTab=3` |
| `SUPER` | `5` | `ActivateTab=4` |
| `SUPER` | `6` | `ActivateTab=5` |
| `SUPER` | `7` | `ActivateTab=6` |
| `SUPER` | `8` | `ActivateTab=7` |
2020-06-20 22:42:39 +03:00
| `SUPER` | `9` | `ActivateTab=-1` |
2020-12-26 09:43:58 +03:00
| `CTRL+SHIFT` | `w` | `CloseCurrentTab{confirm=true}` |
2020-05-22 09:09:57 +03:00
| `CTRL+SHIFT` | `1` | `ActivateTab=0` |
| `CTRL+SHIFT` | `2` | `ActivateTab=1` |
| `CTRL+SHIFT` | `3` | `ActivateTab=2` |
| `CTRL+SHIFT` | `4` | `ActivateTab=3` |
| `CTRL+SHIFT` | `5` | `ActivateTab=4` |
| `CTRL+SHIFT` | `6` | `ActivateTab=5` |
| `CTRL+SHIFT` | `7` | `ActivateTab=6` |
| `CTRL+SHIFT` | `8` | `ActivateTab=7` |
2020-06-20 22:42:39 +03:00
| `CTRL+SHIFT` | `9` | `ActivateTab=-1` |
2020-05-22 09:09:57 +03:00
| `SUPER+SHIFT` | `[` | `ActivateTabRelative=-1` |
2021-05-03 02:07:30 +03:00
| `CTRL+SHIFT` | `Tab` | `ActivateTabRelative=-1` |
| `CTRL` | `PageUp` | `ActivateTabRelative=-1` |
2020-05-22 09:09:57 +03:00
| `SUPER+SHIFT` | `]` | `ActivateTabRelative=1` |
2021-05-03 02:07:30 +03:00
| `CTRL` | `Tab` | `ActivateTabRelative=1` |
| `CTRL` | `PageDown` | `ActivateTabRelative=1` |
2020-11-24 21:13:41 +03:00
| `CTRL+SHIFT` | `PageUp` | `MoveTabRelative=-1` |
| `CTRL+SHIFT` | `PageDown` | `MoveTabRelative=1` |
| `SHIFT` | `PageUp` | `ScrollByPage=-1` |
| `SHIFT` | `PageDown` | `ScrollByPage=1` |
2021-05-03 02:07:30 +03:00
| `ALT` | `1` | `ActivateTab=0` |
| `ALT` | `2` | `ActivateTab=1` |
| `ALT` | `3` | `ActivateTab=2` |
| `ALT` | `4` | `ActivateTab=3` |
| `ALT` | `5` | `ActivateTab=4` |
| `ALT` | `6` | `ActivateTab=5` |
| `ALT` | `7` | `ActivateTab=6` |
| `ALT` | `8` | `ActivateTab=7` |
2020-05-22 18:05:59 +03:00
| `ALT` | `9` | `ShowTabNavigator` |
| `SUPER` | `r` | `ReloadConfiguration` |
| `CTRL+SHIFT` | `R` | `ReloadConfiguration` |
| `SUPER` | `h` | `HideApplication` (macOS only) |
2021-02-06 00:10:08 +03:00
| `SUPER` | `k` | `ClearScrollback="ScrollbackOnly"` |
| `CTRL+SHIFT` | `K` | `ClearScrollback="ScrollbackOnly"` |
2021-08-15 00:15:05 +03:00
| `CTRL+SHIFT` | `L` | `ShowDebugOverlay` (*Since: 20210814-124438-54e29167*)|
2020-06-05 18:07:46 +03:00
| `SUPER` | `f` | `Search={CaseSensitiveString=""}` |
| `CTRL+SHIFT` | `F` | `Search={CaseSensitiveString=""}` |
| `CTRL+SHIFT` | `X` | `ActivateCopyMode` |
2021-09-16 00:16:38 +03:00
| `CTRL+SHIFT` | ` ` (`Space`) | `QuickSelect` (*since: 20210502-130208-bff6815d*) |
2020-10-10 19:50:18 +03:00
| `CTRL+SHIFT+ALT` | `"` | `SplitVertical={domain="CurrentPaneDomain"}` |
| `CTRL+SHIFT+ALT` | `%` | `SplitHorizontal={domain="CurrentPaneDomain"}` |
| `CTRL+SHIFT+ALT` | `LeftArrow` | `AdjustPaneSize={"Left", 1}` |
| `CTRL+SHIFT+ALT` | `RightArrow` | `AdjustPaneSize={"Right", 1}` |
| `CTRL+SHIFT+ALT` | `UpArrow` | `AdjustPaneSize={"Up", 1}` |
| `CTRL+SHIFT+ALT` | `DownArrow` | `AdjustPaneSize={"Down", 1}` |
| `CTRL+SHIFT` | `LeftArrow` | `ActivatePaneDirection="Left"` |
| `CTRL+SHIFT` | `RightArrow` | `ActivatePaneDirection="Right"` |
| `CTRL+SHIFT` | `UpArrow` | `ActivatePaneDirection="Up"` |
| `CTRL+SHIFT` | `DownArrow` | `ActivatePaneDirection="Down"` |
| `CTRL` | `Z` | `TogglePaneZoomState` |
2020-05-22 18:05:59 +03:00
2020-09-26 06:06:50 +03:00
If you don't want the default assignments to be registered, you can
disable all of them with this configuration; if you chose to do this,
you must explicitly register every binding.
```lua
return {
disable_default_key_bindings = true,
}
```
2020-05-22 18:05:59 +03:00
## Configuring Key Assignments
2019-12-30 07:41:08 +03:00
2020-04-07 02:32:16 +03:00
These can be overridden using the `keys` section in your `~/.wezterm.lua` config file.
2019-12-30 07:41:08 +03:00
For example, you can disable a default assignment like this:
2020-04-07 02:32:16 +03:00
```lua
local wezterm = require 'wezterm';
return {
keys = {
2021-10-03 19:18:41 +03:00
-- Turn off the default CMD-m Hide action, allowing CMD-m to
-- be potentially recognized and handled by the tab
{key="m", mods="CMD", action="DisableDefaultAssignment"}
2020-04-07 02:32:16 +03:00
}
}
2019-12-30 07:41:08 +03:00
```
2021-10-03 19:10:04 +03:00
The `action` value can be one of the [available key
assignments](lua/keyassignment/index.md). Every action has an example that shows
how to use it.
2019-12-30 07:41:08 +03:00
The `key` value can be one of the following keycode identifiers. Note that not
all of these are meaningful on all platforms:
`Hyper` , `Super` , `Meta` , `Cancel` , `Backspace` , `Tab` , `Clear` , `Enter` ,
`Shift` , `Escape` , `LeftShift` , `RightShift` , `Control` , `LeftControl` ,
`RightControl` , `Alt` , `LeftAlt` , `RightAlt` , `Menu` , `LeftMenu` , `RightMenu` ,
2021-05-07 17:54:24 +03:00
`Pause` , `CapsLock` , `VoidSymbol` , `PageUp` , `PageDown` , `End` , `Home` , `LeftArrow` ,
2019-12-30 07:41:08 +03:00
`RightArrow` , `UpArrow` , `DownArrow` , `Select` , `Print` , `Execute` ,
`PrintScreen` , `Insert` , `Delete` , `Help` , `LeftWindows` , `RightWindows` ,
`Applications` , `Sleep` , `Numpad0` , `Numpad1` , `Numpad2` , `Numpad3` ,
`Numpad4` , `Numpad5` , `Numpad6` , `Numpad7` , `Numpad8` , `Numpad9` , `Multiply` ,
`Add` , `Separator` , `Subtract` , `Decimal` , `Divide` , `NumLock` , `ScrollLock` ,
`BrowserBack` , `BrowserForward` , `BrowserRefresh` , `BrowserStop` ,
`BrowserSearch` , `BrowserFavorites` , `BrowserHome` , `VolumeMute` ,
`VolumeDown` , `VolumeUp` , `MediaNextTrack` , `MediaPrevTrack` , `MediaStop` ,
`MediaPlayPause` , `ApplicationLeftArrow` , `ApplicationRightArrow` ,
2021-03-09 18:47:27 +03:00
`ApplicationUpArrow` , `ApplicationDownArrow` , `F1` , `F2` , `F3` , `F4` ,
`F5` , `F6` , `F7` , `F8` , `F9` , `F10` , `F11` , `F12` , `F13` , `F14` , `F15` ,
`F16` , `F17` , `F18` , `F19` , `F20` , `F21` , `F22` , `F23` , `F24` .
2019-12-30 07:41:08 +03:00
Alternatively, a single unicode character can be specified to indicate
pressing the corresponding key.
Possible Modifier labels are:
* `SUPER` , `CMD` , `WIN` - these are all equivalent: on macOS the `Command` key,
on Windows the `Windows` key, on Linux this can also be the `Super` or `Hyper`
key. Left and right are equivalent.
* `SHIFT` - The shift key. Left and right are equivalent.
* `ALT` , `OPT` , `META` - these are all equivalent: on macOS the `Option` key,
on other systems the `Alt` or `Meta` key. Left and right are equivalent.
2021-05-07 17:54:24 +03:00
* `VoidSymbol` - This keycode is emitted in special cases where the original
function of the key has been removed. Such as in Linux and using `setxkbmap` .
`setxkbmap -option caps:none` . The `CapsLock` will no longer function as
before in all applications, instead emitting `VoidSymbol` .
2019-12-30 07:41:08 +03:00
You can combine modifiers using the `|` symbol (eg: `"CMD|CTRL"` ).
2020-10-10 19:57:38 +03:00
### Leader Key
2020-11-01 01:51:08 +03:00
*Since: 20201031-154415-9614e117*
2020-10-10 19:57:38 +03:00
A *leader* key is a a modal modifier key. If leader is specified in the
configuration then pressing that key combination will enable a virtual `LEADER`
modifier.
While `LEADER` is active, only defined key assignments that include
`LEADER` in the `mods` mask will be recognized. Other keypresses
will be swallowed and NOT passed through to the terminal.
`LEADER` stays active until a keypress is registered (whether it
matches a key binding or not), or until it has been active for
the duration specified by `timeout_milliseconds` , at which point
it will automatically cancel itself.
Here's an example configuration using `LEADER` . In this configuration,
pressing `CTRL-A` activates the leader key for up to 1 second (1000
milliseconds). While `LEADER` is active, the `|` key (with no other modifiers)
will trigger the current pane to be split.
```lua
local wezterm = require 'wezterm';
return {
-- timeout_milliseconds defaults to 1000 and can be omitted
leader = { key="a", mods="CTRL", timeout_milliseconds=1000 },
keys = {
{key="|", mods="LEADER", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
-- Send "CTRL-A" to the terminal when pressing CTRL-A, CTRL-A
{key="a", mods="LEADER|CTRL", action=wezterm.action{SendString="\x01"}},
}
}
```
2021-05-07 17:59:26 +03:00
### VoidSymbol
2021-08-15 00:15:05 +03:00
*Since: 20210814-124438-54e29167*
2021-05-07 17:59:26 +03:00
On X11 systems, If you decide to change certain keys on the keyboard to
`VoidSymbol` (like `CapsLock` ), then you can utilize it as a `LEADER` or any
other part of key bindings. The following example now uses `VoidSymbol` and
uses `CapsLock` as a `LEADER` without it affecting the shift / capital state as
long as you have `setxkbmap -option caps:none` configured.
2021-05-07 17:54:24 +03:00
```lua
local wezterm = require 'wezterm';
return {
-- timeout_milliseconds defaults to 1000 and can be omitted
-- for this example use `setxkbmap -option caps:none` in your terminal.
leader = { key="VoidSymbol", mods="", timeout_milliseconds=1000 },
keys = {
{key="|", mods="LEADER", action=wezterm.action{SplitHorizontal={domain="CurrentPaneDomain"}}},
{key="-", mods="LEADER", action=wezterm.action{SplitVertical={domain="CurrentPaneDomain"}}},
}
}
```
2021-02-20 20:43:37 +03:00
### Using Raw/Scan Codes for key bindings
In some cases it is desirable to assign keys based on their
physical position rather than their mapped value--perhaps you
regularly switch between different regional keymaps but you always
want CTRL-SHIFT plus a number to switch to a tab by ordinal
position, and you don't want to define the mapping in terms of `!` ,
`@` etc. in the US map and whatever those keys are in some other
regional keymap.
You can achieve this by matching the `raw_key` value for the key.
`raw_key` values are hardware and windowing system dependent
values, so there is no portable way to list which key does what.
To discover these values, you can set [debug_key_events =
true](lua/config/debug_key_events.md) and press the keys of
interest.
You can specify a raw key value of 123 by using `key="raw:123"` in your config
rather than one of the other key values.
On my linux system the number key row produces sequential raw key values so I
use configuration like this to enable this key binding; notice how the numbers
are different between wayland and X11 on the same system!
```lua
local wezterm = require 'wezterm';
local keys = {};
local enable_wayland = false;
if wezterm.target_triple == "x86_64-unknown-linux-gnu" then
-- rebind CTRL+SHIFT+< number > to switch to a tab.
if os.getenv("WAYLAND_DISPLAY") and enable_wayland then
local tab_no = 0
for i = 2, 9 do
table.insert(keys, {
key="raw:"..tostring(i),
mods="CTRL|SHIFT",
action=wezterm.action{ActivateTab=tab_no},
})
tab_no = tab_no + 1
end
else
local tab_no = 0
for i = 10, 20 do
table.insert(keys, {
key="raw:"..tostring(i),
mods="CTRL|SHIFT",
action=wezterm.action{ActivateTab=tab_no},
})
tab_no = tab_no + 1
end
end
end
return {
keys = keys,
enable_wayland = enable_wayland,
}
```
2020-10-10 18:40:14 +03:00
# Available Actions
2019-12-30 07:41:08 +03:00
2020-10-10 18:40:14 +03:00
See the [`KeyAssignment` reference ](lua/keyassignment/index.md ) for information
on available actions.
2019-12-30 07:41:08 +03:00