ShortcutContext
Methods
addShortcut
shortcutContext.addShortcut(options)
Add a keyboard shortcut to this context.
| Param | Type | Default | Description |
|---|---|---|---|
| options | object | The shortcut’s options | |
| options.keys | Array<Array<string>> | Names of the shortcut’s keys, in lowercase or uppercase, unified across browsers. You can use KeyboardEvent.key values, such as ArrowLeft, and the Handsontable-specific control/meta virtual key name. control/meta matches Control on Windows and Linux, and Meta on macOS. | |
| options.callback | function | The shortcut’s action | |
| options.group | object | A group of shortcuts to which the shortcut belongs | |
| [options.runOnlyIf] | object | optional A condition on which the shortcut’s action runs | |
| [options.stopPropagation] | object | false | optional If set to true: stops the event’s propagation |
| [options.captureCtrl] | object | false | optional If set to true: captures the state of the Control/Meta modifier key |
| [options.preventDefault] | object | true | optional If set to true: prevents the default behavior |
| [options.position] | object | ’after’ | optional The order in which the shortcut’s action runs: 'before' or 'after' the relativeToGroup group of actions. The action goes next to the first action of that group. When you add several actions next to the same group, the newest one runs first. |
| [options.relativeToGroup] | object | optional The name of a group of actions, used to determine an action’s position | |
| [options.forwardToContext] | object | optional The context object where the event will be forwarded to. |
addShortcuts
shortcutContext.addShortcuts(shortcuts, [options])
Add multiple keyboard shortcuts to this context.
| Param | Type | Default | Description |
|---|---|---|---|
| shortcuts | Array<object> | List of shortcuts to add to this shortcut context | |
| [options] | object | optional A shortcut’s options | |
| [options.callback] | function | optional A shortcut’s action | |
| [options.group] | object | optional A group of shortcuts to which a shortcut belongs | |
| [options.runOnlyIf] | object | optional A condition on which a shortcut’s action runs | |
| [options.stopPropagation] | object | false | optional If set to true: stops the event’s propagation |
| [options.preventDefault] | object | true | optional If set to true: prevents the default behavior |
| [options.position] | object | ’after’ | optional The order in which a shortcut’s action runs: 'before' or 'after' a relativeToGroup group of actions. The action goes next to the first action of that group. When you add several actions next to the same group, the newest one runs first. |
| [options.relativeToGroup] | object | optional The name of a group of actions, used to determine an action’s position | |
| [options.forwardToContext] | object | optional The context object where the event will be forwarded to. |
getShortcuts
shortcutContext.getShortcuts(keys) ⇒ Array
Get a shortcut’s details.
| Param | Type | Description |
|---|---|---|
| keys | Array<string> | Names of the shortcut’s keys, in lowercase or uppercase, unified across browsers. You can use KeyboardEvent.key values, such as ArrowLeft, and the Handsontable-specific control/meta virtual key name. control/meta matches Control on Windows and Linux, and Meta on macOS. |
hasShortcut
shortcutContext.hasShortcut(keys) ⇒ boolean
Check if a shortcut exists in this context.
| Param | Type | Description |
|---|---|---|
| keys | Array<string> | Names of the shortcut’s keys, in lowercase or uppercase, unified across browsers. You can use KeyboardEvent.key values, such as ArrowLeft, and the Handsontable-specific control/meta virtual key name. control/meta matches Control on Windows and Linux, and Meta on macOS. |
removeShortcutsByGroup
shortcutContext.removeShortcutsByGroup(group)
Remove a group of shortcuts from this context.
| Param | Type | Description |
|---|---|---|
| group | string | The name of the group of shortcuts |
removeShortcutsByKeys
shortcutContext.removeShortcutsByKeys(keys)
Remove a shortcut from this context.
| Param | Type | Description |
|---|---|---|
| keys | Array<string> | Names of the shortcut’s keys, in lowercase or uppercase, unified across browsers. You can use KeyboardEvent.key values, such as ArrowLeft, and the Handsontable-specific control/meta virtual key name. control/meta matches Control on Windows and Linux, and Meta on macOS. |