Code carried out when a key is pressed or released.
<console.onKeyDown.push <if <eq key, 32> then=<putLn {/space}>>> sends /space whenever the space bar is pressed.<msg:input onKeyDown=<if <eq key, 13> then=<putLn msg>, <msg.clear>>> sends the text when Enter is pressed in the input box.A code field: holds code to be carried out each time the event happens. Add code after the tag is created with .push.
While the code runs, key holds a number identifying the key (not the character it types):
| Key | key | Key | key |
|---|---|---|---|
| A to Z | 65 to 90 | Enter | 13 |
| 0 to 9 | 48 to 57 | Space | 32 |
| Left, Up, Right, Down | 37 to 40 | Backspace | 8 |
| Shift | 16 | Tab | 9 |
| Ctrl | 17 |
Key events go to the tag the user is typing in, and also to the console. Use the console's onKeyDown to respond to keys anywhere.