简体   繁体   中英

What's the Linux equivalent of Window's GetAsyncKeyState?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM