glemy/io

Input/Output.

Listens to user interactions — keyboard and mouse events — and exposes them as polling queries (see io_ffi.mjs) for a runner (like glemy/game_tiers’s own loop) to read once per frame and fold into whatever Input a specific game’s own tick function expects — not read by glemy/physics itself, which has no concept of input at all. Polling composes naturally with a frame loop: “is this key down right now” instead of needing to buffer/replay events between frames — this is also the shape kitten-engine (an existing, if immature, Gleam canvas-game engine found during the development-plan research) uses for the same reason.

JavaScript-target only — real input is DOM events, which don’t exist on the Erlang/BEAM target.

Values

pub fn is_key_down(key: String) -> Bool

Whether key is currently held down. key matches the browser KeyboardEvent.key value (e.g. "a", "ArrowUp", " " for space).

pub fn is_mouse_button_down(button: Int) -> Bool

Whether mouse button is currently held down. button matches the browser MouseEvent.button value (0 = primary/left, 1 = middle, 2 = secondary/right).

pub fn mouse_position() -> vector2.Vector2

The mouse’s current position, in CSS pixels relative to the viewport (i.e. MouseEvent.clientX/clientY).

Search Document