SDL_Keymod(3type)

πŸ’– SDL_Keymod πŸ’–

okay so bestie, welcome to the SDL_Keymod page, straight out of the SDL3 DATATYPES section. this is the whole vibe of keyboard modifiers in SDL3, and it's lowkey iconic. ✨


✨ NAME ✨

SDL_Keymod β€” valid key modifiers (possibly OR'd together). no cap, that's literally it. πŸ’…


🌸 SYNOPSIS 🌸

first you gotta bring in the header:

#include <SDL3/SDL_keycode.h>

then you got the actual type, which is just a lil Uint16 in a trench coat:

typedef Uint16 SDL_Keymod;

and here come ALL the defines, exactly as they are, don't touch a single character:

#define SDL_KMOD_NONE   0x0000u /**< no modifier is applicable. */
#define SDL_KMOD_LSHIFT 0x0001u /**< the left Shift key is down. */
#define SDL_KMOD_RSHIFT 0x0002u /**< the right Shift key is down. */
#define SDL_KMOD_LEVEL5 0x0004u /**< the Level 5 Shift key is down. */
#define SDL_KMOD_LCTRL  0x0040u /**< the left Ctrl (Control) key is down. */
#define SDL_KMOD_RCTRL  0x0080u /**< the right Ctrl (Control) key is down. */
#define SDL_KMOD_LALT   0x0100u /**< the left Alt key is down. */
#define SDL_KMOD_RALT   0x0200u /**< the right Alt key is down. */
#define SDL_KMOD_LGUI   0x0400u /**< the left GUI key (often the Windows key) is down. */
#define SDL_KMOD_RGUI   0x0800u /**< the right GUI key (often the Windows key) is down. */
#define SDL_KMOD_NUM    0x1000u /**< the Num Lock key (may be located on an extended keypad) is down. */
#define SDL_KMOD_CAPS   0x2000u /**< the Caps Lock key is down. */
#define SDL_KMOD_MODE   0x4000u /**< the !AltGr key is down. */
#define SDL_KMOD_SCROLL 0x8000u /**< the Scroll Lock key is down. */
#define SDL_KMOD_CTRL   (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL)   /**< Any Ctrl key is down. */
#define SDL_KMOD_SHIFT  (SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT) /**< Any Shift key is down. */
#define SDL_KMOD_ALT    (SDL_KMOD_LALT | SDL_KMOD_RALT)     /**< Any Alt key is down. */
#define SDL_KMOD_GUI    (SDL_KMOD_LGUI | SDL_KMOD_RGUI)     /**< Any GUI key is down. */

#endif /* SDL_keycode_h_ */

πŸŽ€ the modifiers, one by one πŸŽ€

these are the individual flags, and yes they can be OR'd together, so you can stack them like accessories. 🫢

  • SDL_KMOD_NONE β€” 0x0000u: no modifier is applicable. it's giving absolutely nothing, and honestly? sometimes that's the moment. πŸ’€
  • SDL_KMOD_LSHIFT β€” 0x0001u: the left Shift key is down.
  • SDL_KMOD_RSHIFT β€” 0x0002u: the right Shift key is down.
  • SDL_KMOD_LEVEL5 β€” 0x0004u: the Level 5 Shift key is down. rare, fancy, main character energy. πŸ‘‘
  • SDL_KMOD_LCTRL β€” 0x0040u: the left Ctrl (Control) key is down.
  • SDL_KMOD_RCTRL β€” 0x0080u: the right Ctrl (Control) key is down.
  • SDL_KMOD_LALT β€” 0x0100u: the left Alt key is down.
  • SDL_KMOD_RALT β€” 0x0200u: the right Alt key is down.
  • SDL_KMOD_LGUI β€” 0x0400u: the left GUI key is down. that's often the Windows key, iykyk. πŸͺŸ
  • SDL_KMOD_RGUI β€” 0x0800u: the right GUI key is down. also often the Windows key. no cap.
  • SDL_KMOD_NUM β€” 0x1000u: the Num Lock key is down, and it may be located on an extended keypad. slay, extended keypad. πŸ”’
  • SDL_KMOD_CAPS β€” 0x2000u: the Caps Lock key is down. YOU KNOW WHAT THAT MEANS. 😭
  • SDL_KMOD_MODE β€” 0x4000u: the !AltGr key is down. yes, that exclamation mark is literally in the name, don't come for me.
  • SDL_KMOD_SCROLL β€” 0x8000u: the Scroll Lock key is down. the forgotten icon, still valid. πŸ’œ

🌈 the combined "any of them" ones 🌈

because sometimes you don't care which side, you just want the whole vibe check to pass. ✨

  • SDL_KMOD_CTRL β€” (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL): any Ctrl key is down.
  • SDL_KMOD_SHIFT β€” (SDL_KMOD_LSHIFT | SDL_KMOD_RSHIFT): any Shift key is down.
  • SDL_KMOD_ALT β€” (SDL_KMOD_LALT | SDL_KMOD_RALT): any Alt key is down.
  • SDL_KMOD_GUI β€” (SDL_KMOD_LGUI | SDL_KMOD_RGUI): any GUI key is down.

πŸ¦‹ AVAILABILITY πŸ¦‹

this datatype is available since SDL 3.2.0. so if you're on anything older, bestie, it's not you, it's the version. πŸ’…


and that's the page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, under the title SDL_Keymod(3type). periodt. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from