In addition to event callbacks registered withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dRessedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
GEventAttachKey and GEventAttachClick, LWXGL provides polling functions to read the current mouse and keyboard state at any point within a frame. These are useful for continuous input — e.g. smooth movement — where a callback-per-event model is too coarse.
State is updated by GHandleWindowEvents, so polling before that call each frame will return the state from the previous frame.
GQueryMouse
Output. Set to the cursor’s current X coordinate in window pixels. Set to
-1 when the cursor is outside the window.Output. Set to the cursor’s current Y coordinate in window pixels. Set to
-1 when the cursor is outside the window.Output. Set to the button currently held down (
1=left, 2=middle, 3=right, 4=scroll-up, 5=scroll-down), or 0 if no button is held.GQueryKeyboard
unsigned char[8] array of currently held keys. Each slot contains the character code (ASCII or LWXGL key constant) of one held key, or 0 if that slot is unused. Up to 8 simultaneous keys are tracked.
Returns: Pointer to an internal unsigned char[8] array. Do not free or store this pointer across frames; its contents are updated in-place by GHandleWindowEvents.
For checking a single specific key, prefer
GQueryKeyDown over iterating the array manually.GQueryKeyDown
The character code to check. Accepts ASCII values (e.g.
'a', ' ') or LWXGL key constants:| Constant | Value | Key |
|---|---|---|
LWXGL_KEY_LEFT | 170 | Left arrow |
LWXGL_KEY_RIGHT | 171 | Right arrow |
LWXGL_KEY_UP | 172 | Up arrow |
LWXGL_KEY_DOWN | 173 | Down arrow |
LWXGL_KEY_FN + n | 150+n | F1–F12 |
1 if the key is currently held, 0 otherwise.
Frame-loop example
The polling functions work naturally alongsideGSimpleWindowLoop. Use GQueryKeyDown inside the per-frame callback for smooth, held-key movement:
GHandleWindowEvents is called at the start of each frame by GSimpleWindowLoop, GQueryKeyDown always reflects the latest input state when on_frame runs.