shortcuts([shortcuts])

Class: PasswordField. Method inherited from UIComponent.

Description:

Sets or gets an array of keyboard shortcuts handled by onShortcut() event handler.

Parameters:

Name Type Description

[shortcuts]

Array.<object> | Array.<string>

An array of shortcut objects {shortcut:{string}, scope: {ShortcutScope}, action: {string}}, or an Array of String shortcuts (for strings a default ShortcutScope will be assigned depending on the component type). When user presses the shortcut keys, an event will be emitted to .onShortcut(callback) handler callback, where an action can be determined.

Returns:

If called without arguments, then current shortcuts array is returned, otherwise an instance of this component is returned.

Type: this | Array.<object>

Throws:

Examples:

Setting shortcuts as strings

window.shortcut(["f1", "ctrl+s"]);

Setting shortcuts as objects

window.shortcuts([
    {
        key: "control+s",
        scope: ShortcutScope.Window, // optional
        action: "save_file" // optional, sent with a shortcut event to .onShortcut(callback) callback function
    }
]);

Clearing all shortcuts

window.shortcuts([]); // pass an empty array

Retrieving current shortcuts

const shortcuts = window.shortcuts(); // returns an Array of shortcut objects.

Also See: