Enter a search term above to see results...
On This Page
Key Bindings
Keybindings can be attached to any component by passing in keys
to defineComponent
Types of Bindings
Single keys
Key bindings can be bound to any key by their common name. Multiple key bindings can be bound to the same event using ,
separation.
Special keys are mapped to their common names like ctrl
, alt
, meta
shift
Multiple Keys
Multiple keys can be bound to the same event using a comma separated list.
Key Combinations
Key combinations can be used by including a +
between keys. Spacing is ignored.
Key Sequences
Key sequences can be used by leaving a space between each key. Keys will need to be pressed within a 500ms
interval to be part of the same sequence.
Basic Keybinding Example
Callback Data
In addition to the standard callback data found in lifecycle guide keyboard bindings have access to a couple extra values.
parameter | use |
---|---|
inputFocused | whether any input/contenteditable is focused |
repeatedKey | whether the key is held down |
Dynamic Keybinding
All lifecycle callbacks receive as a parameter two methods bindKey
and unbindKey
which can be used to dynamically add and remove keybindings as necessary.
This is often used with componet reactivity to adjust key bindings when something significant has changed with a component.