I need to get scan codes of keyboard buttons (or any other codes) in layout-independent way. More specific, let's say I have QEditText and catching keystrokes from it. Now I'm starting to press a single button, and when the layout is English it has keycode=X, then I'm switching layout to Russian (German, French, whatever) and keycode becomes Y - but the physical button is the same. So I need to know code of that physical button, how to do this?
我需要以与布局无关的方式获取键盘按钮(或任何其他代码)的扫描码。更具体地说,假设我有QEditText并从中捕捉击键。现在我开始按下一个按钮,当布局为英文时,它的keycode = X,然后我将布局切换为俄语(德语,法语等),键码变为Y - 但物理按钮是相同的。所以我需要知道该物理按钮的代码,该怎么做?
1 个解决方案
#1
1
I am not sure if you will be able to do this only from code itself by some qt/x11 methods, but there is a tool that helps in similar situations: xbindkeys. You can read more here: https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
我不确定你是否能够通过一些qt / x11方法从代码本身做到这一点,但有一个工具可以帮助类似的情况:xbindkeys。你可以在这里阅读更多内容:https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
If you can't use xbindkeys, you can still check its code and see how the author achieved this.
如果您不能使用xbindkeys,您仍然可以检查其代码并查看作者是如何实现此目的的。
#1
1
I am not sure if you will be able to do this only from code itself by some qt/x11 methods, but there is a tool that helps in similar situations: xbindkeys. You can read more here: https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
我不确定你是否能够通过一些qt / x11方法从代码本身做到这一点,但有一个工具可以帮助类似的情况:xbindkeys。你可以在这里阅读更多内容:https://unix.stackexchange.com/questions/91355/shortcut-keys-that-are-independent-to-keyboard-layout
If you can't use xbindkeys, you can still check its code and see how the author achieved this.
如果您不能使用xbindkeys,您仍然可以检查其代码并查看作者是如何实现此目的的。