Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

µDewy is archived and no longer developed. This is a snapshot of its documentation. → Dewy

D.7 Keyboard Input Intrinsics

The WASM backend also exposes keyboard state using browser KeyboardEvent.code strings such as ArrowLeft, ArrowRight, KeyW, and Space:

IntrinsicArgsDescription
__key_down__(code_ptr code_len)2Get whether a key is currently held down
__key_pressed__(code_ptr code_len)2Get whether a key transitioned from up to down since the last animation frame
__key_released__(code_ptr code_len)2Get 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.

While a canvas, WebGL or GPU surface has the page, keys that would scroll it or move focus (arrows, Space, Tab, Backspace, PageUp/PageDown, Home/End, /, ') act only as program input; other keys, and any key held with Ctrl, Alt or Meta, keep their browser behavior. A key press or a click also unlocks audio (D.10).