Linux在Windows中等同于Window的GetAsyncKeyState? [英] What's the Linux equivalent of Window's GetAsyncKeyState?

查看:219
本文介绍了Linux在Windows中等同于Window的GetAsyncKeyState?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c ++,我需要确定是否按下了Shift键.在Windows中,我只能使用GetAsyncKeyState.如何在Linux中执行此操作? 我无法以root用户身份运行.

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.

推荐答案

在X Windows下,您可以加载X Keyboard扩展名并调用XkbGetState()以获取当前的键盘状态.如果按下Shift键,则由XkbGetState()设置的XkbStateRec结构的base_mods字段将设置ShiftMask位.此处的完整文档: https://www. x.org/releases/X11R7.7/doc/libX11/XKB/xkblib.html#Determining_Keyboard_State

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

或者: https://stackoverflow.com/a/4225290/4474419

这篇关于Linux在Windows中等同于Window的GetAsyncKeyState?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆