Top
craft-uikit
craft-widget-

KeyboardManager

KeyboardManager

Source:

Global key-press event manager.

Before you use this utility, you have to call activate.
(You will call this in your bootstrap)

You have to manage your registration key by yourself.

Example

const ESC_KEY = 27;

Craft.Core.KeyboardManager.activate();

const action_id = 'action_name'+this.componentId;

Craft.Core.KeyboardManager.register(action_id,ESC_KEY, () => {
    this.work_when_esc_pressed();
    Craft.Core.KeyboardManager.remove(action_id);
});

Methods

(static) activate()

Source:

Activate KeyboardManager

(static) register(id, key, action)

Source:

Register key-press handler

Parameters:
Name Type Description
id String

identifier

key Number

key number ex) ESC:27

action function

handler

(static) remove(id)

Source:

Remove key-press handler

Parameters:
Name Type Description
id String

identifier

(static) clear()

Source:

Clear all handlers