Keyboard-Layout

將非修飾符配置為修飾鍵

  • January 21, 2019

這個問題類似於:

https://askubuntu.com/questions/33751/making-any-key-into-a-modifier-key

我有一台具有非標準鍵盤佈局(聯想 x1 carbon)的機器,其中 CapsLock 鍵已被 Home、End 取代。我習慣將 CapsLock 映射為控制項,所以我使用 xmodmap 來映射 Home,End 到 Control:

xmodmap -e 'keycode 110 = Control_L' # Home
xmodmap -e 'keycode 115 = Control_L' # End

當我單獨按 Home(或 End)時,會檢測到正確的鍵符:

state 0x0, keycode 110 (keysym 0xffe3, Control_L), same_screen YES,

但是我不能使用重新映射的 Home 或 End 鍵作為任何其他鍵的修飾符:當我按 Control+a 時,a 鍵不會被修改:

KeyPress event, serial 36, synthetic NO, window 0x1000001,
   root 0xe0, subw 0x0, time 15157752, (829,406), root:(830,407),
   state 0x0, keycode 110 (keysym 0xffe3, Control_L), same_screen YES,
   XKeysymToKeycode returns keycode: 37
   XLookupString gives 0 bytes: 
   XmbLookupString gives 0 bytes: 
   XFilterEvent returns: False

KeyPress event, serial 36, synthetic NO, window 0x1000001,
   root 0xe0, subw 0x0, time 15157761, (829,406), root:(830,407),
   state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
   XLookupString gives 1 bytes: (61) "a"
   XmbLookupString gives 1 bytes: (61) "a"
   XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x1000001,
   root 0xe0, subw 0x0, time 15157912, (829,406), root:(830,407),
   state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
   XLookupString gives 1 bytes: (61) "a"
   XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x1000001,
   root 0xe0, subw 0x0, time 15157949, (829,406), root:(830,407),
   state 0x0, keycode 110 (keysym 0xffe3, Control_L), same_screen YES,
   XKeysymToKeycode returns keycode: 37
   XLookupString gives 0 bytes: 
   XFilterEvent returns: False

而如果我使用“真實”控制鍵,則“a”鍵按下具有控制修飾符狀態:

KeyPress event, serial 36, synthetic NO, window 0x1000001,
   root 0xe0, subw 0x0, time 15160488, (829,406), root:(830,407),
   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 0x1000001,
   root 0xe0, subw 0x0, time 15161477, (829,406), root:(830,407),
   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 0x1000001,
   root 0xe0, subw 0x0, time 15161588, (829,406), root:(830,407),
   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 0x1000001,
   root 0xe0, subw 0x0, time 15161842, (829,406), root:(830,407),
   state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
   XLookupString gives 0 bytes: 
   XFilterEvent returns: False

在我的情況下,是否可以將 Home 鍵配置為 Control 修飾鍵?還是有一些硬體限制阻止了這一點?

除了您的兩個命令之外,您還必須添加 Control

xmodmap -e 'keycode 110 = Control_L' # Home

xmodmap -e 'keycode 115 = Control_L' # End

xmodmap -e 'add Control = Control_L'

引用自:https://unix.stackexchange.com/questions/494734