shortcut
Svelte action to add keyboard shortcuts.
See
Type Aliases
KeyboardShortcut
Basic definition of a keyboard shortcut based on key and modifier keys.
Type declaration
alt?
Needs alt ?
ctrl?
Needs ctrl ?
key?
Keyboard key.
shift?
Needs shift ?
Defined in
tmp/commons/src/lib/actions/shortcut.ts:14
ShortcutSettings<E>
Settings for a keyboard shortcut.
Type declaration
action()?
Callback to be triggered when shortcut is activated.
Parameters
• node: E
• e: KeyboardEvent
Returns
unknown
endAction()?
Callback to be triggered when key is released.
Parameters
• node: E
• e: KeyboardEvent
Returns
void
ignoreElements?
Element types that prevents the shortcut from triggering.
Defaults to [‘INPUT’, ‘TEXTAREA’].
repeats?
Should keep triggering if key is still pressed ?
Defaults to true.
shortcuts?
List of shortcuts that trigger the action.
Can be a single shortcut or an array of shortcuts. If a function is provided, it should return a boolean indicating whether the shortcut is triggered based on the keyboard event.
Type Parameters
• E extends Element
Defined in
tmp/commons/src/lib/actions/shortcut.ts:28
Functions
shortcut()
Action to add a keyboard shortcut.
All keyboard listeners are attached to document.
Type Parameters
• E extends Element
Parameters
• node: E
The element the shortcut is bound to
• params: ShortcutSettings
<E
>
Settings for the shortcut
Returns
ActionReturn
<ShortcutSettings
<E
>>
svelte action to add a keyboard shortcut
Defined in
tmp/commons/src/lib/actions/shortcut.ts:173
shortcutToString()
Converts a keyboard shortcut definition to a string.
Parameters
• param0: KeyboardShortcut
Keyboard shortcut definition
Returns
string