al_clear_keyboard_state(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_clear_keyboard_state πŸ’–

okay bestie, welcome to the Allegro 5 API manual, the al_clear_keyboard_state(3alleg5) page, and honestly? this one is a little hero 🫢


✨ NAME ✨

al_clear_keyboard_state β€” the Allegro 5 function that hits the reset button on your whole keyboard state, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

void al_clear_keyboard_state(ALLEGRO_DISPLAY *display)

that's it, that's the whole vibe ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So like. This function clears the state of the keyboard, and it does it loudly β€” it emits ALLEGRO_EVENT_KEY_UP(3alleg5) for each key that is currently pressed. Every single one. It's giving "everyone get up, we're leaving" πŸŽ€

The display you pass in gets treated as the one that had the keyboard focus when the event happened. That matters, okay?

🚨 and if display is NULL? No event is emitted. Not one. Nothing. Silent. πŸ’€

Here's the tea though: for most keyboard drivers, Allegro keeps its own internal state of the keyboard, and that internal state can lowkey get out of sync with the real, actual, physical keyboard. Rude, honestly.

This function exists to fix exactly that situation β€” it resets Allegro's keyboard state to a known default, and that default is no key pressed. Fresh. Clean. Iconic. ✨

It's particularly useful when you're responding to ALLEGRO_EVENT_DISPLAY_SWITCH_OUT(3alleg5) events β€” like when the user tabs away and your poor keyboard state is just sitting there still thinking keys are held down. Not on our watch πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

go read those too, they're part of the friend group 🫢


πŸ‘‘ SINCE πŸ‘‘

5.2.3

⚠️ [Unstable API]: This is a new feature and the exact semantics are still being decided upon.

so like... it works, it slays, but the devs are still figuring out the final form. be cool about it πŸ™ˆ


and that's the page, bestie!! brought to you by the Allegro reference manual β€” al_clear_keyboard_state(3alleg5), stay iconic, clear those keys, mwah πŸ’–πŸŒˆβ­

πŸ“¦ where this page comes from