Quick answer: Pygame key.get_mods() not reporting KMOD_NUM when NumLock is on? SDL on some platforms reports lock states via key events, not the live mods bitmask.
A game wants to know NumLock state for numpad routing; get_mods always returns 0 for KMOD_NUM.
Get Mods Caveats
get_mods returns SDL_GetModState. Lock modifiers (NUM, CAPS, SCROLL) work on most platforms but not all — Wayland is notably finicky.
Track via Events
if event.type == KEYDOWN and event.key == K_NUMLOCK:
numlock_on = not numlock_onMaintain your own state by listening for the toggle key. Cross-platform reliable.
Initial State
On startup, your tracked state is unknown. Query via OS APIs (ctypes on Windows, terminal escape codes elsewhere) or just default to off.
Use Numpad Keys Anyway
K_KP_1 through K_KP_9 always report numpad keys regardless of NumLock. If you care about positions, use the KP_ codes directly.
Verifying
Game responds correctly to NumLock state on all target platforms. Numpad routing works without ambiguity.
“NumLock via get_mods is platform-flaky. Track manually via KEYDOWN.”
Avoid relying on Lock modifiers for gameplay — rebind numpad to direct keys so NumLock state doesn’t matter.