Python 3.x – Getting the state of caps-lock/num-lock/scroll-lock on Windows
You can use ctypes to load user32.dll and then call GetKeyState with nVirtKey = VK_CAPITAL (0x14) def get_capslock_state(): import ctypes hllDll = ctypes.WinDLL (“User32.dll”) VK_CAPITAL = 0x14 return hllDll.GetKeyState(VK_CAPITAL)