D.7 Keyboard Input Intrinsics
The WASM backend also exposes keyboard state using browser KeyboardEvent.code strings such as ArrowLeft, ArrowRight, KeyW, and Space:
| Intrinsic | Args | Description |
|---|---|---|
__key_down__(code_ptr code_len) | 2 | Get whether a key is currently held down |
__key_pressed__(code_ptr code_len) | 2 | Get whether a key transitioned from up to down since the last animation frame |
__key_released__(code_ptr code_len) | 2 | Get whether a key transitioned from down to up since the last animation frame |
These intrinsics are intended for animated WASM programs running under canvas or WebGL, where main() is called once per frame.