DataGridXL - API

KeyboardObserver

Description

The KeyboardObserver listens for keyboard events and notifies the grid of relevant key presses, such as [kbd:Ctrl+A] to select all.

Usage

Your DataGridXL instance contains a property keys.

javascript
// create DataGridXL instance
const grid = new DataGridXL(...);
// work with the KeyboardObserver instance
grid.keys.on('ctrl+a', () => ...);
NOTE: You don't need to create a KeyboardObserver instance yourself — it is provided by the grid automatically.

Methods

activate()

Activate keyboard observer

block()

Block any matching key actions from executing

deactivate()

Deactivate keyboard observer

off(keyCommand, callbackFn, repeat?, target?)

Remove a listener to a specific keyCommand

Arguments

keyCommand
stringThe key command, like `ctrl+a`
callbackFn
functionCallback function
repeat?
booleandefault trueWhether to repeat the action while the key is held down
target?
nullHTMLElementdefault nullHTMLElement that needs to have focus for command to work
on(keyCommand, callbackFn, repeat?, target?)

Add a listener to a specific keyCommand

Arguments

keyCommand
stringThe key command, like `ctrl+a`
callbackFn
functionCallback function
repeat?
booleandefault trueWhether to repeat the action while the key is held down
target?
nullHTMLElementdefault nullHTMLElement that needs to have focus for command to work
unblock()

Unblock any matching key actions from executing

No generated events found for KeyboardObserver.