SDL_GetModState(3)

πŸ’… SDL_GetModState πŸ’…

okay bestie, listen up β€” this is a page from the SDL3 FUNCTIONS collection, and today's main character is SDL_GetModState. she's small, she's simple, and she's about to tell you exactly which modifier keys your keyboard is holding down right now. shift? ctrl? alt? gui? she knows. she always knows. πŸ‘‘


🌸 NAME 🌸

SDL_GetModState β€” get the current key modifier state for the keyboard. no cap, that's literally the whole job description. πŸ’–


✨ SYNOPSIS ✨

#include <SDL3/SDL_keyboard.h>

SDL_Keymod SDL_GetModState(void);

okay so you include the header, you call her with no arguments at all β€” she takes void, she needs nothing from you β€” and she hands you back an SDL_Keymod. she's low maintenance like that. πŸŽ€


πŸ¦‹ RETURN VALUE πŸ¦‹

She returns an OR'd combination of the modifier keys for the keyboard. 🫢

that's it. that's the tea. it's giving bitmask, it's giving "every modifier currently held gets its own bit OR'd together." you want to check for one specific one? you AND it, bestie. iykyk. πŸ’…


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this function from any thread. 🌈

so go off, spawn all the threads you want, she does not care. main character energy means being available to everyone. πŸ’œ


⭐ AVAILABILITY ⭐

This function has been available since SDL 3.2.0. she's not new new, but she's not ancient either β€” she's in her prime. πŸ‘‘


πŸ’– SEE ALSO πŸ’–


fr fr though β€” remember she only reports the modifier keys. for the full keys-down situation you're gonna want her friend in SEE ALSO. don't get it twisted. 😭

and that's a wrap, bestie! πŸŽ€ this page came to you from Simple Directmedia Layer, documenting SDL 3.4.18 β€” mwah, slay, go write some keyboard code, you absolute icon. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from