Class: Accelerator

Accelerator

Keyboard Accelerator support used by menu (if available) and user-registered keys. Also works for user-defined keys independent of the menu system. Automatically instantiated when used with WindowManager.

new Accelerator ()

Methods

clearKeys ()

clear all user-registered keys

clearMenuKeys ()

clears all menu keys

prettifyKey (keyCode)string

Make the KeyCode pretty for printing on the menu
Name Type Description
keyCode KeyCode
Returns:
Type Description
string

register (keyCode, callback)

register a key as a global accelerator
Name Type Description
keyCode Accelerator~KeyCodes (e.g., Ctrl+shift+E)
callback function

registerAlt (pressed, released)

special key registration for alt
Name Type Description
pressed function
released function

registerMenuShortcut (letter, menuItem, applicationMenu)

Register a shortcut key for use by an open menu
Name Type Description
letter Accelerator~KeyCodes
menuItem MenuItem
applicationMenu boolean

registerMenuSpecial (menuItem)

Register special shortcut keys for menu
Name Type Description
menuItem MenuItem

unregisterMenuShortcuts ()

Removes menu shortcuts

Type Definitions

KeyCodes string

Keycodes definition. In the form of modifier[+modifier...]+key

For example: ctrl+shift+e

KeyCodes are case insensitive (i.e., shift+a is the same as Shift+A). And spaces are removed

You can assign more than one key to the same shortcut by using a | between the keys (e.g., 'shift+a | ctrl+a')

Modifiers:
   ctrl, alt, shift, meta, (ctrl aliases: command, control, commandorcontrol)
Keys:
   escape, 0-9, minus, equal, backspace, tab, a-z, backetleft, bracketright, semicolon, quote,
   backquote, backslash, comma, period, slash, numpadmultiply, space, capslock, f1-f24, pause,
   scrolllock, printscreen, home, arrowup, arrowleft, arrowright, arrowdown, pageup, pagedown,
   end, insert, delete, enter, shiftleft, shiftright, ctrlleft, ctrlright, altleft, altright, shiftleft,
   shiftright, numlock, numpad...
For OS-specific codes and a more detailed explanation see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code. Also note that 'Digit' and 'Key' are removed from the code to make it easier to type.