0.1.2
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.
(Array<string> | Array<Array<string>>)
:
The cleaned array shortcut.
Create a unique ID every time it is called.
number
:
A unique ID.
The main class to access the features of the KeyCuts library.
(HTMLElement)
The HTML element that should listen to
keyboard shortcuts (if not provided then Window object is used).
(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. |
The name of the default scope.
Bind a keyboard shortcut. A shortcut can be in string or array format.
(string)
An optional scope.
(Function)
The callback that should be triggered.
The callback gets called with the current key or combo sequence
and the key event.
number
:
The unique ID of the bound handler.
Unbind keyboard shortcut handlers having the specified scope.
(String)
The scope.
Unbind all keyboard shortcut handlers.
Unbind all watchers.
Switch the scope. Only bound handlers get triggered that have the new scope. The default scope can be accessed by Keys.DEFAULT_SCOPE.
(number)
The scope.
Stop listening to key events and reset the key sequence.
Resume listening to key events.
Parse a string shortcut and return the equivalent array shortcut.
(string)
The string shortcut to convert.
(Array<string> | Array<Array<string>>)
:
The converted array shortcut.
Create equivalent string shortcut of an array shortcut.
string
:
The converted string shortcurt.