keypressed(3alleg4)

πŸ’– keypressed β€” Allegro manual, bestie edition πŸ’–

okay so you're deep in the Allegro game programming library (hi, we love her) and you need to know if somebody's mashing keys at you. that's literally this whole page. let's go πŸŽ€


✨ NAME ✨

keypressed β€” tells if there are keypresses waiting in the input buffer. part of the Allegro game programming library. periodt. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <allegro.h>

int keypressed();

πŸ¦‹ DESCRIPTION πŸ¦‹

so keypressed() returns TRUE if there are keypresses waiting in the input buffer. that's it, that's the function, she's simple and she ate. πŸ’…

why do you care tho? two iconic reasons, bestie:

  • you wanna peek and see if the next call to readkey() is gonna block on you (spoiler: it will, if there's nothing in the buffer 😭)
  • or you just wanna wait for the user to press a key while you keep updating the screen, possibly drawing some animation. main character multitasking energy. no cap. ✨

like, here's the vibe:

while (!keypressed()) {
   /* Show cool animated logo. */
}
/* So he skipped our title screen. */

see how that works? while nothing's been pressed, you keep looping and drawing your cool animated logo (slay), and the instant somebody hits a key, you bail out of the loop. iconic. and yes, the comment is right β€” if they pressed something, they skipped your title screen. rude but valid. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie, you're officially keypressed-literate 🫢

this was brought to you by Allegro version 4.4.3 β€” yes that's the version, that's the source, and this little manpage is keypressed(3alleg4). go forth and check your input buffer, queen πŸ’œπŸŒΈβœ¨