Skip to content

ShortcutContext

Methods

addShortcut

Source code

shortcutContext.addShortcut(options)

Add a keyboard shortcut to this context.

ParamTypeDefaultDescription
optionsobjectThe shortcut’s options
options.keysArray<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.callbackfunctionThe shortcut’s action
options.groupobjectA group of shortcuts to which the shortcut belongs
[options.runOnlyIf]objectoptional A condition on which the shortcut’s action runs
[options.stopPropagation]objectfalseoptional If set to true: stops the event’s propagation
[options.captureCtrl]objectfalseoptional If set to true: captures the state of the Control/Meta modifier key
[options.preventDefault]objecttrueoptional 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]objectoptional The name of a group of actions, used to determine an action’s position
[options.forwardToContext]objectoptional The context object where the event will be forwarded to.

addShortcuts

Source code

shortcutContext.addShortcuts(shortcuts, [options])

Add multiple keyboard shortcuts to this context.

ParamTypeDefaultDescription
shortcutsArray<object>List of shortcuts to add to this shortcut context
[options]objectoptional A shortcut’s options
[options.callback]functionoptional A shortcut’s action
[options.group]objectoptional A group of shortcuts to which a shortcut belongs
[options.runOnlyIf]objectoptional A condition on which a shortcut’s action runs
[options.stopPropagation]objectfalseoptional If set to true: stops the event’s propagation
[options.preventDefault]objecttrueoptional 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]objectoptional The name of a group of actions, used to determine an action’s position
[options.forwardToContext]objectoptional The context object where the event will be forwarded to.

getShortcuts

Source code

shortcutContext.getShortcuts(keys) ⇒ Array

Get a shortcut’s details.

ParamTypeDescription
keysArray<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

Source code

shortcutContext.hasShortcut(keys) ⇒ boolean

Check if a shortcut exists in this context.

ParamTypeDescription
keysArray<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

Source code

shortcutContext.removeShortcutsByGroup(group)

Remove a group of shortcuts from this context.

ParamTypeDescription
groupstringThe name of the group of shortcuts

removeShortcutsByKeys

Source code

shortcutContext.removeShortcutsByKeys(keys)

Remove a shortcut from this context.

ParamTypeDescription
keysArray<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.