d_keyboard_proc(3alleg4)

πŸ’– d_keyboard_proc πŸ’–

okay bestie, so this is a page from the Allegro manual, and it's literally all about d_keyboard_proc β€” the invisible little dialog procedure that makes keyboard shortcuts happen. yes, invisible. she's not like other dialog objects, she's behind the scenes. main character energy but make it stealth mode πŸ«₯✨


✨ NAME ✨

d_keyboard_proc β€” the invisible dialog procedure for implementing keyboard shortcuts. part of the Allegro game programming library, and honestly? iconic for it. πŸ’…


🌸 SYNOPSIS 🌸

#include <allegro.h>

int d_keyboard_proc(int msg, DIALOG *d, int c);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: this is an invisible object for implementing keyboard shortcuts. that's it, that's her whole job. no visuals, no drama, just vibes and keypresses. πŸŽ€

now, how do you tell her which keys to listen for? you've got options, and she's flexible:

  • drop an ASCII code into the key field of the dialog object. that could be a character like 'a' when you wanna respond to a simple keypress, or a number 1-26 when you wanna respond to a control key a-z. cute, right?
  • orrrr you can put a keyboard scancode in the d1 and/or d2 fields. yes, "and/or" β€” she's accommodating like that. πŸ’–

and the moment one of those keys gets pressed? 🎹 she calls the function pointed to by dp. that function should return an int, which gets passed right back to the dialog manager, so it can return D_O_K, D_REDRAW, D_CLOSE, etc. whatever it's feeling fr fr. ✨

no cap: the return value actually matters here β€” it's how the dialog manager finds out what you want to do next. don't sleep on it. 😭

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie, you ate that πŸ’…

this was brought to you by the Allegro manual, version 4.4.3 β€” mwah, stan her, periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹