key_shifts(3alleg4)
π key_shifts β the Allegro manual, bestie edition β¨
okay so. this is key_shifts(3alleg4) from the Allegro manual, aka the Allegro game programming library. buckle up π
β¨ NAME β¨
key_shifts β a bitmask containing the current state of the modifier keys. it lives in the Allegro game programming library, and it is literally the vibe check for your keyboard's mood π
πΈ SYNOPSIS πΈ
#include <allegro.h>
extern volatile int key_shifts;
that's it. that's the whole thing. a single volatile int. iconic behaviour, no notes π
π¦ DESCRIPTION π¦
so key_shifts is a bitmask holding the current state of shift / ctrl / alt, the special Windows keys, and the accent escape characters. she's holding a LOT of info in one little int and honestly? slay. π
wherever possible this value gets updated asynchronously β like, she's doing her own thing, no input from you required. BUT π¨ if keyboard_needs_poll() returns TRUE, then bestie you have to manually call poll_keyboard() to refresh it with the current input state. no cap, that's on you. don't forget it.
this value can contain any of these flags:
KB_SHIFT_FLAGKB_CTRL_FLAGKB_ALT_FLAGKB_LWIN_FLAGKB_RWIN_FLAGKB_MENU_FLAGKB_COMMAND_FLAGKB_SCROLOCK_FLAGKB_NUMLOCK_FLAGKB_CAPSLOCK_FLAGKB_INALTSEQ_FLAGKB_ACCENT1_FLAGKB_ACCENT2_FLAGKB_ACCENT3_FLAGKB_ACCENT4_FLAG
π example (yes it's giving main character energy) π
if (key[KEY_W]) {
if (key_shifts & KB_SHIFT_FLAG) {
/* User is pressing shift + W. */
} else {
/* Hmmm... lower case W then. */
}
}
see how she reads? bitwise & and suddenly you know whether the user is screaming W or just gently typing w. the range?? unmatched πβ¨
π SEE ALSO π
go read those too, they're the rest of the friend group π«Ά
and that's the whole page, bestie π brought to you by Allegro, version 4.4.3, on the key_shifts(3alleg4) page. mwah, take care of your modifier 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