cleanShortcut

Clean an array shortcut. The array is cleaned in-place and also returned. Unnecessary white space is removed, key combinations are sorted and single chars converted to lower case.

cleanShortcut(shortcut: (Array<string> | Array<Array<string>>)): (Array<string> | Array<Array<string>>)
Parameters
shortcut ((Array<string> | Array<Array<string>>)) The array shortcut to clean.
Returns
(Array<string> | Array<Array<string>>): The cleaned array shortcut.

generateId

Create a unique ID every time it is called.

generateId(): number
Returns
number: A unique ID.

Keys

The main class to access the features of the KeyCuts library.

new Keys(element: HTMLElement, options: Object)
Parameters
element (HTMLElement) The HTML element that should listen to keyboard shortcuts (if not provided then Window object is used).
options (Object) Additional options (optional).
Name Description
options.triggerOncePerKey boolean If a key is kept down then the shortcut will be triggered multiple times when set to false and only once when set to true (default: false)
options.useCodeInsteadKey boolean If set to false then KeyboardEvent.key is evaluated for triggering shortcuts, otherwise KeyboardEvent.code (default: false)
options.maxSequenceLength number The maximum sequence of key or combos that should be tracked (default: 3)
options.filter Function A filter function. If the filter returns false the event will be filtered out and no bound handler or watcher will be triggered. The filter function will be called with the key event. The default filter will always return true.
Static Members
DEFAULT_SCOPE
Instance Members
bind
unbind
unbindScope
unbindAll
watch
unwatch
unwatchAll
switchScope
stop
resume

parseShortcut

Parse a string shortcut and return the equivalent array shortcut.

parseShortcut(shortcut: string): (Array<string> | Array<Array<string>>)
Parameters
shortcut (string) The string shortcut to convert.
Returns
(Array<string> | Array<Array<string>>): The converted array shortcut.

stringifyShortcut

Create equivalent string shortcut of an array shortcut.

stringifyShortcut(shortcut: (Array<string> | Array<Array<string>>)): string
Parameters
shortcut ((Array<string> | Array<Array<string>>)) The array shortcut to convert.
Returns
string: The converted string shortcurt.