`wezterm` allows assigning action(s) to specific key events, and comes
pre-configured with a number of commonly useful assignments.
This page describes how key presses are handled and turned into actions
or sent to the terminal as text.
It's important to understand these concepts when considering keyboard input;
first, some operating system concepts:
* *Input Method Editor* (IME) - An OS-provided service which allows
for rich composition of input, often with a pop-over candidate
selection window. This is commonly used for Asian input, but on
some systems the IME may also be responsible for emoji input or
dead keys. The IME may have multiple modes per language and those
modes can be changed dynamically.
* *Keyboard Layout* - An OS configuration that describes how to translate
physical key button presses into inputs appropriate to the user's
preferred input locale. The mapping performed by the layout is
largely opaque to applications and, on most systems, can be changed
dynamically.
* *Dead Key* - a keyboard layout may define these modal keys
which don't immediately produce output (and thus appears to be "dead"),
but instead holds some state that will compose with a subsequently
pressed key. Most commonly used for example in European layouts to
produce accented versions of the plain latin alphabet.
* *Physical Key* - a way to identify a key based on its hardware-dependent location. `wezterm` can refer to keys based on code they would emit if configured to use an ANSI US English keyboard layout (even if that layout is not currently active), or based on its raw scan code.
* *Mapped key* - a way to identify a key after the keyboard layout has been applied by the OS.
* *Modifier* - A key such as `SHIFT`, `CTRL`, `CMD`, `ALT` that can be held simultaneously while other keys are pressed. Modifier keys are special because keyboard hardware traditionally only supports those four modifiers, and that detail is ingrained into most OS input APIs.
And then some wezterm concepts:
* *Key Assignment* - an action assigned to a matching key and modifier combination.
* *Key Table* - a grouping of key assignments. For each window, `wezterm` maintains a stack of table activations, allowing for rich modal keyboard input customization
## Keyboard Processing Flow
This schematic depicts the processing flow for keyboard events in `wezterm`:
```mermaid
flowchart TD
A[OS Generates a Key Event]
A --> B{{Is IME enabled?}}
B -->|Yes| C[Deliver event to IME] --> C1{{IME Response}}