Skip to content
tactile

Key syntax & bindings

A binding is a string (or array of strings). Tactile parses it into one or more chords — a single keystroke with modifier flags and a main key.

Join keys with +:

'mod+shift+k'
'ctrl+alt+delete'
'alt+enter'

Separate strokes with spaces. Each stroke must complete within sequenceTimeout (default 1000ms):

'g i' // press g, then i
'ctrl+k ctrl+s' // two combos in sequence

Resolves per platform — meta (⌘) on macOS, ctrl on Windows/Linux:

'mod+k' // ⌘K on Mac, Ctrl+K elsewhere

Write one binding instead of maintaining separate Mac/Windows strings.

Pass an array — any variant matches:

keys: ['mod+k', 'ctrl+p']
kb.add({ id: 'save', keys: 'mod+s', handler: save });
kb.add({ id: 'inbox', keys: 'g i', handler: goToInbox });
kb.add({ id: 'open', keys: ['mod+o', 'mod+p'], handler: open });
kb.add({ id: 'help', keys: '?', handler: help });
kb.add({ id: 'delete-line', keys: 'ctrl+shift+delete', handler: deleteLine });
Alias Modifier
ctrl, control Control
shift Shift
alt, option, opt Alt / Option
cmd, command, meta, win, super Meta / Command
mod Meta on macOS, Control elsewhere
Category Tokens
Editing enter, esc, space, tab, backspace, delete, insert
Arrows up, down, left, right (aliases: arrowup, etc.)
Navigation home, end, pageup, pagedown
Function f1 through f24
Other capslock

Type directly or spell out:

Glyph Spelled
?
/ slash
+ plus
- minus
. period, dot
, comma
; semicolon
' quote
` backtick
= equal, equals
~ tilde
\ backslash

Use an empty segment: ctrl++ binds Ctrl + the plus key.

Invalid bindings throw KeybindingParseError at registration time:

kb.add({ id: 'bad', keys: 'ctrl+', handler: fn }); // Error: expected a key
kb.format('mod+shift+p'); // '⇧⌘P' on macOS, 'Ctrl+Shift+P' elsewhere

Labels come from the binding string, not the current OS keyboard layout. See International keyboards.

kb.add({ id: 'a', keys: 'mod+z', match: 'hybrid', handler: undo }); // default
kb.add({ id: 'b', keys: 'mod+z', match: 'logical', handler: undoAlt }); // character
kb.add({ id: 'c', keys: 'mod+z', match: 'physical', handler: undoPhys }); // keycap

See Match modes.