![xev 表示 Caps Lock 重新映射已起作用,但其他应用程序看不到它](https://linux22.com/image/1369458/xev%20%E8%A1%A8%E7%A4%BA%20Caps%20Lock%20%E9%87%8D%E6%96%B0%E6%98%A0%E5%B0%84%E5%B7%B2%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%8C%E4%BD%86%E5%85%B6%E4%BB%96%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%9C%8B%E4%B8%8D%E5%88%B0%E5%AE%83.png)
我正在尝试将 Caps Lock 重新映射到 Control。在我修改任何内容之前,xev
按下/释放 Caps Lock 时会报告以下内容:
KeyPress event, serial 73, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 50243576, (82,130), root:(1365,612),
state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
PropertyNotify event, serial 73, synthetic NO, window 0x2600001,
atom 0x17c (XKLAVIER_STATE), time 50243577, state PropertyNewValue
PropertyNotify event, serial 73, synthetic NO, window 0x2600001,
atom 0x17c (XKLAVIER_STATE), time 50243579, state PropertyNewValue
KeyRelease event, serial 73, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 50243680, (82,130), root:(1365,612),
state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
我运行以下命令来重新映射:
xmodmap -e 'remove Lock = Caps_Lock'
xmodmap -e 'keysym Caps_Lock = Control_L'
xmodmap -e 'add Lock = Caps_Lock'
xmodmap -e 'clear Lock'
xmodmap -e 'keycode 66 = Control_L'
现在,关于 Caps Lock 的新闻/发布会xev
报道:
KeyPress event, serial 80, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 50785441, (11,140), root:(1294,622),
state 0x0, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
XKeysymToKeycode returns keycode: 37
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 80, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 50785521, (11,140), root:(1294,622),
state 0x0, keycode 66 (keysym 0xffe3, Control_L), same_screen YES,
XKeysymToKeycode returns keycode: 37
XLookupString gives 0 bytes:
XFilterEvent returns: False
这似乎没问题,但该键在所有其他应用程序中仍可用作 Caps Lock。我确实注意到,当我按下“真正的”左控制键时,没有XKeysymToKeycode
,但我不知道这是什么意思。
以下是真正按下/释放左 Ctrl 键的事件:
KeyPress event, serial 37, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 57111640, (176,176), root:(188,272),
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x2600001,
root 0x290, subw 0x0, time 57111736, (176,176), root:(188,272),
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False