Keys
Handle key combination events.
Static Member Summary
Static Public Members | ||
public static |
The time allowed between keypresses for a sequence in miliseconds
|
Static Method Summary
Static Public Methods | ||
public static |
filterInputs(event: *): Boolean The default keycombo event filter function. |
|
public static |
Convert a key to its character code representation. |
Constructor Summary
Public Constructor | ||
public |
constructor(elOrSelector: *, options: Object) |
Method Summary
Public Methods | ||
public |
Destroy this instance. |
|
public |
Initialize an instance created without the |
|
public |
Remove a key combo listener. |
|
public |
Add a key combo listener. |
|
public |
Reset the state of this instance. |
Static Public Members
Static Public Methods
public static filterInputs(event: *): Boolean source
The default keycombo event filter function. Ignores key combos triggered on input, select, and textarea.
Params:
Name | Type | Attribute | Description |
event | * | The event passed |
Public Constructors
public constructor(elOrSelector: *, options: Object) source
Params:
Name | Type | Attribute | Description |
elOrSelector | * | The selector or element to listen for keyboard events on. This should be the common parent of all elements you wish to listen for events on. |
|
options | Object |
|
Options for this combo handler. |
options.context | Function |
|
The desired value of the |
options.preventDefault | Function |
|
Whether to prevent the default behavior when a key combo is matched. |
options.stopPropagation | Function |
|
Whether to stop propagation when a key combo is matched. |
options.filter | Function |
|
The filter function for keyboard events. This can be used to stop events from being triggered when they originate from specific elements. Defaults to Keys.filterInputs. |
Public Methods
public destroy(globalsOnly: Boolean): Keys source
Destroy this instance. This removes all event listeners, references, and state.
Params:
Name | Type | Attribute | Description |
globalsOnly | Boolean | Whether only global listeners should be removed |
public init(globalsOnly: Boolean): Keys source
Initialize an instance created without the new
keyword or revive a destroyed instance. This method
will be called automatically if an instance is created with new Coral.keys
.
Params:
Name | Type | Attribute | Description |
globalsOnly | Boolean | Whether only global listeners should be added |
public off(keyCombo: String, selector: String, listener: Function): Keys source
Remove a key combo listener.
public on(keyCombo: String, selector: String, data: String, listener: Function): Keys source
Add a key combo listener.
Params:
Name | Type | Attribute | Description |
keyCombo | String | The key combination to listen for, such as |
|
selector | String |
|
A selector to use for event delegation. |
data | String |
|
Data to pass to listeners as |
listener | Function | The listener to execute when this key combination is pressed. Executes on keydown, or, if too many keys are pressed and one is released, resulting in the correct key combination, executes on keyup. |