Keyboard-Layout

使用 xcape 將 Caps Lock 映射到 Ctrl 和 Esc 後將 Esc 重新映射到 Caps Lock

  • February 15, 2017

我目前已經通過這些命令Caps Lock映射到Ctrl何時按住和Esc點擊(對於vim).xinitrc

setxkbmap -option 'caps:ctrl_modifier'
xcape -e 'Caps_Lock=Escape'

這可行,但讓我沒有Caps Lock,所以我想重新映射EscCaps Lock. 我試過設置它,xmodmap -e 'keycode 9 = Caps_Lock'但這也覆蓋了Caps Lock鍵上的映射。有沒有辦法實現這些映射?

Caps Lock -> Ctrl and Esc
Esc -> Caps Lock

您可以使用setxkbmapxmodmap交換 Caps Lock 和 Escape。xmodmap你可以擁有:

! Remove Caps_Lock modifier from real Caps Lock key
clear Lock
! Set real Caps Lock key to present as (left) control
keycode 66 = Control_L
! Set real Escape key to present as Caps Lock
keycode 9 = Caps_Lock
! Make a fake key to hold the Escape keysym, so xcape can use it
keycode 255 = Escape
! Make Caps_Lock and Control_L work as one would expect
add Lock = Caps_Lock
add Control = Control_L

(以開頭的行!是註釋。)

將其放入~/.xmodmaprc並執行xmodmap ~/.xmodmaprc,然後執行xcape -e '#66=Escape'以將 Escape 功能添加到真正的 Caps Lock 鍵。

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