根据密钥所在的设备映射密钥? (Linux)
我拥有一个 Razer Naga 鼠标,本质上它有一个侧面有一个小数字键盘。我想将这些键重新映射到不同的未使用的键或 bash 命令。我可以通过使用 xev 获取键码(例如鼠标上的“1”是键码 87)来轻松完成此操作,然后我可以使用 xmodmap 将键码绑定到不同的键。
然而,我键盘上的小键盘也会继承这一点,因为键码是相同的,但我注意到“串行”是不同的。
例如,这是当按下鼠标小键盘上的“1”按钮时 xev 的输出。
KeyPress event, serial 34, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179878, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179966, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
这是在键盘数字键盘上按“1”时的输出
KeyPress event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180261, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180341, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
我是否可以根据此映射鼠标上的按键?
I own a Razer Naga Mouse, essentaly it has a small numpad on the side of it. I want to remap these keys to different unused keys or to bash commands. I can do this easily by using xev to grab the keycode (for instance the "1" on the mouse is keycode 87) and then I can use xmodmap to bind the keycode to a different key.
However the numpad on my keyboard will also inherit this as the keycode is the same, what I noticed though is that the "serial" is different.
For instance here is the output from xev when pressing the "1" button on my mouse numpad.
KeyPress event, serial 34, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179878, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2179966, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and here is the output when pressing "1" on my keyboards numpad
KeyPress event, serial 35, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180261, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1c00001,
root 0x1ae, subw 0x0, time 2180341, (170,-2), root:(198,345),
state 0x0, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Is there anyway I could map the keys on my mouse based on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
setxkbmap
,而不是xmodmap
和xkbcomp
。xkbcomp
命令允许您指定输入设备 ID(使用-i
选项)。要获取设备 ID 列表,请运行
xinput --list
。 (FWIW,我的 Razer Salmosa 明确标记为“Razer Razer Salmosa”。)以下是我如何将 USB 键盘 (ID 16) 转换为使用德语键映射,同时将笔记本电脑键盘保留在美国映射上:
我真的不知道知道如何设置
xkb
映射,但我发现一个 看起来相当不错的教程。Instead of
xmodmap
, try usingsetxkbmap
andxkbcomp
. Thexkbcomp
command lets you specify an input device ID (using the-i
option).To get a list of device IDs run
xinput --list
. (FWIW, my Razer Salmosa was clearly labeled as "Razer Razer Salmosa".)Here's how I converted my USB keyboard (ID 16) to use the German key mapping, while keeping my laptop keyboard on a US mapping:
I don't really know how to set up
xkb
mappings, but I found a tutorial that looks pretty good.好的解决了。按照此 wiki 上的说明进行操作 https://github.com/graph/Razer-Naga-HotKey/wiki/How-to-get-Razer-Naga-HotKeying-Working-on-Debian
Ok Solved. Follow instructions on this wiki https://github.com/graph/Razer-Naga-HotKey/wiki/How-to-get-Razer-Naga-HotKeying-Working-on-Debian