ureadkey(3alleg4)
β¨ ureadkey β¨
okay bestie, gather round, because this one is a certified bop π it lives in the Allegro game programming library, and it does one thing and does it gorgeously: it hands you the next unicode character from the keyboard buffer. no cap. π
πΈ SYNOPSIS πΈ
#include <allegro.h>
int ureadkey(int *scancode);
that's it. that's the whole vibe. one include, one function, infinite slay. π¦
π DESCRIPTION π
so here's the tea, fr fr: ureadkey returns the next character from the keyboard buffer, in Unicode format. and if the buffer is literally empty? it just waits. sits there. patiently. like a bestie holding your spot in line until a key gets pressed. π«Ά
wanna know if there are already queued keypresses chilling in there before you commit? that's what keypressed() is for, go check it, iykyk. π
the return value carries the Unicode value of the key. and if that pointer argument isn't NULL, it gets set to the scancode β so you get both the character and the physical key info. main character energy honestly. π
and the way that readkey() could never β because unlike readkey(), this function is able to return character values greater than 255. that's the whole point. that's the flex. π
β¨
example time, because we love a demo:
int val, scancode;
...
val = ureadkey(&scancode);
if (val == 0x00F1)
allegro_message("You pressed n with tilde\n");
if (val == 0x00DF)
allegro_message("You pressed sharp s\n");
look at her go ππ those are the exact magic numbers, don't touch them.
you should be able to find Unicode character maps over at http://www.unicode.org/ β go wild, go browse, it's giving reference material π
β οΈ DOS besties listen up!! remember that on DOS you must specify a custom keyboard map (like those found inkeyboard.dat) β usually with the help of a configuration file specifying the language mapping (thekeyboardvariable in the system section ofallegro.cfg). if you don't? you get the default US keyboard mapping. that's not a vibe check you want to fail. π
π SEE ALSO π
install_keyboard(3alleg4)readkey(3alleg4)keypressed(3alleg4)clear_keybuf(3alleg4)simulate_ukeypress(3alleg4)exkeys(3alleg4)
go read them all, they're all iconic in their own way π§π
Allegro Β· version 4.4.3 Β· ureadkey(3alleg4)
and that's the whole page bestie, mwah, go press some keys ππΈπ
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms