Overview
Theglide.keys API provides methods for sending keyboard events, capturing key presses, and parsing key notation. This is useful for automating interactions, creating interactive prompts, and building custom key-based workflows.
Methods
send()
Send a key sequence to the browser, simulating physical key presses.The key sequence to send. Can include:
- Regular characters:
a,b,c,1,2,!,@, etc. - Special keys:
<Space>,<Enter>,<Tab>,<Esc>,<BS>, etc. - Arrow keys:
<Left>,<Right>,<Up>,<Down> - Function keys:
<F1>,<F2>, …,<F12> - Modifiers:
<C-...>(Ctrl),<S-...>(Shift),<A-...>(Alt),<D-...>(Cmd/Super) - Leader key:
<leader>(expands toglide.g.mapleader, default<Space>)
If
true, send the key events directly to Firefox’s input handler, bypassing all Glide keymaps. Default: falseA promise that resolves when all key events have been sent.
Key notation is case-insensitive for special keys:
<space>, <Space>, and <SPACE> are all equivalent.next()
Returns a Promise that resolves to a KeyEvent when the next key is pressed.A promise that resolves to a KeyEvent object containing:
key: The character representation of the keyglide_key: The vim notation of the key (e.g.,<C-s>)ctrlKey,shiftKey,altKey,metaKey: Modifier states- All standard KeyboardEvent properties
next_str()
Returns a Promise that resolves to a string representation of the next key pressed.A promise that resolves to the Glide key notation string (e.g.,
d, <C-l>, <Space>).next() that returns only the glide_key string.
next_passthrough()
Capture the next key press without preventing its default behavior.A promise that resolves to a KeyEvent object. Unlike
next(), the key event continues to be processed normally.Use
next_passthrough() when you want to inspect key presses without interfering with their normal behavior. This is useful for debugging or monitoring.parse()
Parse a single key notation string into a structured object.A single key in Glide notation (e.g.,
<C-a>, j, <Space>).An object containing:
key: The key character or special key namealt: Whether Alt/Option is pressedctrl: Whether Ctrl is pressedmeta: Whether Cmd/Super is pressedshift: Whether Shift is pressed
Special keys are normalized to be consistent. Shifted keys are not special-cased - the returned key is whatever was given in the input.Examples:
<Space>→{ key: "<Space>" }H→{ key: "H" }<S-h>→{ key: "h", shift: true }<S-H>→{ key: "H", shift: true }
Complete Examples
Custom Confirmation Prompt
glide.ts
Multi-Key Command
glide.ts
Auto-Type Sequence
glide.ts
Capture and Replay
glide.ts
Special Key Reference
View all supported keys
View all supported keys
Basic Keys
- Letters:
a-z,A-Z - Numbers:
0-9 - Symbols:
!@#$%^&*()-_=+[]{}\|;:'",./<>?
<Space>,<Tab>,<Enter>,<CR>,<Return><Esc>,<BS>,<Backspace>,<Del>,<Delete><Insert>
<Up>,<Down>,<Left>,<Right><Home>,<End><PageUp>,<PgUp>,<PageDown>,<PgDn>
<F1>through<F12>
<C-...>: Ctrl<S-...>: Shift<A-...>: Alt/Option<M-...>: Alt/Option (alias)<D-...>: Cmd/Super
<k0>through<k9><kPlus>,<kMinus>,<kMultiply>,<kDivide><kEnter>,<kPoint>
<AudioVolumeUp>,<AudioVolumeDown>,<AudioVolumeMute><MediaPlayPause>,<MediaStop>,<MediaTrackNext>,<MediaTrackPrevious>
<BrowserBack>,<BrowserForward>,<BrowserRefresh><BrowserStop>,<BrowserSearch>,<BrowserFavorites>,<BrowserHome>
<leader>: Expands toglide.g.mapleader(default<Space>)<lt>: Literal<character<Bar>: Literal|character<Bslash>: Literal\character