I'm using c++, and I need to determine if a shift key is pressed. In windows, I can just use GetAsyncKeyState. How can I do this in Linux? I cannot run as root.
Asked
Active
Viewed 5,572 times
1 Answers
1
Under X Windows, you can load the X Keyboard extension and call XkbGetState() to get the current keyboard state. If the shift key is being pressed, the base_mods field of the XkbStateRec structure set by XkbGetState() will have the ShiftMask bit set. Full documentation here: https://www.x.org/releases/X11R7.7/doc/libX11/XKB/xkblib.html#Determining_Keyboard_State
Alternatively: https://stackoverflow.com/a/4225290/4474419