React Data Grid ShortcutContext

Description

The ShortcutContext API lets you store and manage keyboard shortcuts in a given context.

Each ShortcutContext object stores and manages its own set of keyboard shortcuts.

Methods

addShortcut

Source code (opens new window)

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, (coming from KeyboardEvent.key (opens new window)), in lowercase or uppercase, unified across browsers
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 true 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
[options.relativeToGroup] object optional The name of a group of actions, used to determine an action's position

addShortcuts

Source code (opens new window)

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 true 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
[options.relativeToGroup] object optional The name of a group of actions, used to determine an action's position

getShortcuts

Source code (opens new window)

shortcutContext.getShortcuts(keys) ⇒ Array

Get a shortcut's details.

Param Type Description
keys Array<string> Names of the shortcut's keys, (coming from KeyboardEvent.key (opens new window)), in lowercase or uppercase, unified across browsers

hasShortcut

Source code (opens new window)

shortcutContext.hasShortcut(keys) ⇒ boolean

Check if a shortcut exists in this context.

Param Type Description
keys Array<string> Names of the shortcut's keys, (coming from KeyboardEvent.key (opens new window)), in lowercase or uppercase, unified across browsers

removeShortcutsByGroup

Source code (opens new window)

shortcutContext.removeShortcutsByGroup(group)

Remove a group of shortcuts from this context.

Param Type Description
group string The name of the group of shortcuts

removeShortcutsByKeys

Source code (opens new window)

shortcutContext.removeShortcutsByKeys(keys)

Remove a shortcut from this context.

Param Type Description
keys Array<string> Names of the shortcut's keys, (coming from KeyboardEvent.key (opens new window)), in lowercase or uppercase, unified across browsers
Last update: Apr 3, 2024