是否有可能在XMonad中对L_GUI +键和R_GUI +键进行不同的绑定,如果是,那么如何? 同样的问题是R_CTRL,R_SFT和R_ALT,但它们对我来说并不那么重要。
答案 0 :(得分:1)
对于这些问题,有人可能会问xev它对你的按键有什么看法。这是我按下左控制+ a和右控制+ a:
的一些示例输出KeyPress event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207488563, (419,468), root:(2341,612),
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207489283, (419,468), root:(2341,612),
state 0x4, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XmbLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207489403, (419,468), root:(2341,612),
state 0x4, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207490035, (419,468), root:(2341,612),
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207538195, (-175,35), root:(1747,179),
state 0x0, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207538595, (-175,35), root:(1747,179),
state 0x4, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XmbLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207538715, (-175,35), root:(1747,179),
state 0x4, keycode 38 (keysym 0x61, a), same_screen YES,
XLookupString gives 1 bytes: (01) ""
XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1400001,
root 0x2a9, subw 0x0, time 4207539227, (-175,35), root:(1747,179),
state 0x4, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
正如您所看到的,虽然左控制和右控制在按下时会产生不同的按键,但在按下另一个按键时它们会产生相同的状态。因此,我无法在当前的设置中区分它们。
如果您想让它们成为不同的修饰符,可以使用xmodmap进行排列;但是,修饰符的总数有限 - 我想可能有四个左右。但请参阅xmodmap文档了解详细信息。
答案 1 :(得分:1)
我不熟悉L_GUI键,但通常可以为键提供不同的映射,前提是它们返回不同的代码。确定这一点的简单方法是使用xev
。在xev
运行时,键入一个键会导致两个事件,一个用于按键,一个用于键释放。
我有爱尔兰键盘。当我运行xev
并键入左Alt键时,事件为:
KeyPress event, serial 33, synthetic NO, window 0xe00001,
root 0x1dc, subw 0x0, time 4233053053, (748,263), root:(1711,266),
state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0xe00001,
root 0x1dc, subw 0x0, time 4233053237, (748,263), root:(1711,266),
state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
所以键码是64.注意keysim是Alt_l
。为了映射这个键,我会查看Graphics.X11.Types并发现该键的常量是xK_Alt_L
。
当我在键盘上按右Alt键(标记为Alt Gr)时,我得到一个不同的键码,108。所以我可以有不同的绑定。
KeyPress event, serial 33, synthetic NO, window 0xe00001,
root 0x1dc, subw 0x0, time 4233053813, (748,263), root:(1711,266),
state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
XKeysymToKeycode returns keycode: 92
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 33, synthetic NO, window 0xe00001,
root 0x1dc, subw 0x0, time 4233053989, (748,263), root:(1711,266),
state 0x90, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
XKeysymToKeycode returns keycode: 92
XLookupString gives 0 bytes:
XFilterEvent returns: False
我可能错了,但我认为美国键盘会为左右Alt键返回相同的键码。在这种情况下,密钥不能有不同的绑定。