Description of icon
Flex UI
API Reference

KeyboardShortcutManager

Keyboard shortcut manager which can be used to edit or disable Flex UI keyboard shortcuts.


addShortcuts(newKeyboardShortcuts) => void#

Add new keyboard shortcuts alongside the default shortcuts provided.

Parameters:

  • newKeyboardShortcuts: KeyboardShortcuts

    The object containing keyboard shortcuts to be added

    • key: string - The key to be associated with the keyboard shortcut
    • shortcut: KeyboardShortcut - The keyboard shortcut object
      • action: function - The action which is triggered by the shortcut
      • name: string - The name of the shortcut which will be displayed in error messages if a shortcut does not work
      • throttle?: number - The optional throttle time in ms which can be set to prevent the shortcut from being triggered again within the set amount of time. A notification will show if a shortcut is used repeatedly within the throttle limit time

Returns:

  • void

Example:

Flex.KeyboardShortcutManager.addShortcuts({
5: { action: () => console.log("hello"), name: "Hello" },
D: { action: toggleDialpad, name: "Toggle dialpad", throttle: 100 }
});

deleteShortcuts(keys) => void#

Delete keyboard shortcuts from the default shortcuts provided.

Parameters:

  • keys: Array<string>

    An array containing one or more keys corresponding to the shortcuts to be deleted

Returns:

  • void

Example:

Flex.KeyboardShortcutManager.deleteShortcuts(["S", "A", "1"]);

remapShortcut(oldKey, newKey, shortcut?) => void#

Remap a keyboard shortcut from the default key provided to another chosen key. This should be repeated for each shortcut which need to be remapped.

Parameters:

  • oldKey: string

    The letter of the key which the default shortcut corresponds to

  • newKey: string

    The new key to assign to the shortcut

  • shortcut?: KeyboardShortcut

    An optional object to be passed if any modifications need to be made to the shortcut itself

    • action: function - The action which is triggered by the shortcut
    • name: string - The name of the shortcut which will be displayed in error messages if a shortcut does not work
    • throttle?: number - The optional throttle time in ms which can be set to prevent the shortcut from being triggered again within the set amount of time. A notification will show if a shortcut is used repeatedly within the throttle limit time

Returns:

  • void

Example:

Flex.KeyboardShortcutManager.remapShortcut("S", "K");
Flex.KeyboardShortcutManager.remapShortcut("S", "K", {
action: Flex.defaultActions.toggleActivityMenu,
name: "Toggle Activity Menu",
throttle: 1000
});

disableShortcuts() => void#

Disable keyboard shortcuts entirely for Flex UI.

Returns:

  • void

Example:

Flex.KeyboardShortcutManager.disableShortcuts();
Rate this page

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.