scancode_to_ascii(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– scancode_to_ascii β€” the Allegro manual, but make it cute πŸ’–

okay so bestie, this one lives in section 3 of the Allegro manual, and it's part of the Allegro game programming library. she's a little function with a big job: turning a scancode into an actual character. let's get into it πŸŽ€


✨ NAME ✨

scancode_to_ascii β€” literally converts a scancode to an ASCII character. that's it, that's the whole gig. Allegro game programming library, periodt. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int scancode_to_ascii(int scancode);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” scancode_to_ascii takes the scancode you hand it and converts it into the ASCII character for that key. mangling Unicode values, no cap. what you get back is the unshifted, uncapslocked result of pressing that key. so like, the plainest possible version of that character, no shift energy, no caps lock drama. πŸ™ˆ

and if the key isn't a character-generating key? or the lookup just can't happen at all? you get zero. that's the answer, that's it. ✨

the lookup literally cannot be done for keys like the F1-F12 keys or the cursor keys β€” they're just not giving character, iykyk. 😭 and some drivers will only return approximate values, so don't come for her if it's a little off.

πŸ’€ real talk: if your goal is showing the user the name of a key, do NOT use this one. use the scancode_to_name function instead. she's the one you want for that job, fr fr.

Example, since a visual always eats:

int ascii;
...
ascii = scancode_to_ascii(scancode);
allegro_message("You pressed '%c'\n", ascii);

look at her go 🫢


🌈 SEE ALSO 🌈


and that's the whole page bestie!! this was the Allegro manual, version 4.4.3, and yeah we're rolling with that same footer energy β€” go forth and convert those scancodes πŸ‘‘β­πŸ§š

πŸ“¦ where this page comes from