How to swap ctrl and caps lock using xmodmap
15,047
Solution 1
From Remap Caps Lock :
man xmodmap shows how to swap the left control key and the CapsLock key:
! ! Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L
Solution 2
This may work for you.
/usr/bin/setxkbmap -option "ctrl:swapcaps"
Solution 3
Swap:
setxkbmap -option "ctrl:swapcaps"
Reverse the swap:
setxkbmap -option
Reference: please click here
Related videos on Youtube
Author by
Maruti
Updated on September 18, 2022Comments
-
Maruti almost 2 years
Or any other tool, but I prefer xmodmap. I tried this:
remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L
I also tried this:
xmodmap -e "keycode 66 = Control_L"
But neither seem to fully work. Here's the event log for pressing caps lock:
KeyPress event, serial 28, synthetic NO, window 0x1a00001, root 0x12d, subw 0x0, time 914826, (679,342), root:(680,362), state 0x12, keycode 66 (keysym 0xffe3, Control_L), same_screen YES, XKeysymToKeycode returns keycode: 37 // 37 is the control key code XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False
I'm running Ubuntu 10.10 with awesome window manager.
-
Mikko Rantalainen about 3 yearsI'd try to directly map keycodes to intended behavior. For example, I like to bind my caps lock key as additional shift and hide the normal caps lock behavior behind shift (so to enable/disable caps lock on my keyboard shift+caps lock is required):
xmodmap -e "keycode 66 = Shift_L Caps_Lock"
. -
Admin about 2 yearsRegarding "other tools" see also linux - Remap keys without xmodmap or any X tools - Super User. I think it's more reliable because it works with some "lower-level" applications while using X does not work with e.g. anydesk
-
-
Maruti about 13 yearsUhm, that's my first attempt in my post.
-
harrymc about 13 yearsOups, missed that. Then why did it work this time?
-
Maruti about 13 yearsI'm not sure. I think I forgot to reset the keymap after meddling with keycodes.
-
SLN over 5 yearsHow can I swap it back by setxbmap