onKey([callback], [remove])

Class: SplitView. Method inherited from UIComponent.

Description:

Gets, registers or unregisters a keyboard keys' event handler function.

Parameters:

Name Type Default Description

[callback]

function

The event handler function that receives a KeyEvent object. Pass null to unregister all handler functions.

[remove]

boolean

false

Set to true to unregister the event handler.

Returns:

An array of handler functions if no arguments are passed, otherwise this component for method chaining.

Type: this | Array.<function()>

Examples:

// Example event object:
const e = {
  target: object,           // The component that triggered the event.
  type: string,             // `up`, `down`, `type`.
  keyCode: number           // Numeric code associated with the key
  extendedKeyCode: number   // The extended key code is a unique id assigned to a key on the keyboard just like keyCode. However, unlike keyCode, this value depends on the current keyboard layout.
  keyChar: string           // Key character
  modifiers: number,        // Keyboard modifiers (bitmask or flags).
  modifiersText: string     // Modifiers representation as a string.
  alt: boolean,             // Indicates if ALT key was pressed.
  shift: boolean,           // Indicates if SHIFT key was pressed.
  ctrl: boolean,            // Indicates if CTRL key was pressed.
  keyLocation: string       // `standard`, `numpad`, `left`, `right`. Location of the key on keyboard. Only present when type is `up` or `down`.
};

Also See: