WLEvent.buildOnKey()
Overview
Create a string to represent the event name for a specified key code. This is a helper function. We recommend using WLEvent.onKey() in most cases.
Use case
Used by scripts to generate named events for specific key presses.
Format
WLEvent.buildOnKey(keyCode);
Parameter | Description | Type | Required | Notes |
---|---|---|---|---|
keyCode | The key code to use. | Number or string | Required | May be the numeric value of a key, or the string encoded numeric value of a key, or a named key. For key values, see Keyboard Codes and Commands. |
Example 1
Copy
/* Number example.
* The value is returned as a keycode event in the OnKey<HHHH> format.
*/
var keyEvent = WLEvent.buildOnKey(27); /* 'OnKey<001B>' */
Example 2
Copy
/* String example.
* The value is returned as a keycode event in the OnKey<HHHH> format.
*/
var keyEvent = WLEvent.buildOnKey("27"); /* 'OnKey<001B>' */
Example 3
Copy
/* Named key example.
* The value is returned as a keycode event in the OnKey<HHHH> format.
*/
var keyEvent = WLEvent.buildOnKey("F1"); /* 'OnKey<E03B>' */
Example 4
Copy
/* Hex value example.
* All F1 key handlers are removed from all scopes.
*/
WLEvent.off(WLEvent.buildOnKey(0xE03B)); /* calls WlEvent.off() with 'OnKey<E03B>' *//