How do I remap the caps lock key?
Solution 1
From howtogeek.com which has a good answer for any OS.
For Linux (including Ubuntu):
setxkbmap -option <OPTION>
Where <OPTION>
can be for example of:
-
caps:none
– Disables Caps Lock. -
caps:super
– Caps Lock becomes an additional Super (aka Win key). -
caps:ctrl_modifier
– Caps Lock becomes an additional Ctrl. -
caps:numlock
– Caps Lock becomes an additional Num Lock. -
caps:escape
– Caps Lock becomes an additional Escape. -
caps:backspace
– Caps Lock becomes an additional Backspace. -
caps:swapescape
– Caps Lock becomes Escape, and Escape becomes Caps Lock
Note: Xmodmap is deprecated in favor of setxkbmap.
Solution 2
In Ubuntu 11.10 - 13.04
- Open the Keyboard Layout application and click the "Options" button.
- A list of rebinding options will apear. Select "Caps Lock key behavior".
- Select your preferred Caps Lock repurposing option.
Solution 3
You can disable it by going to keyboard->Layouts->options->caps lock behavior and choose "disable caps lock" .
Edit:
I don't know why it seems inconvenient with another Keyboard keys.
But Launchy works fine with me after trying it with CTRL+Super+Space.
And you need to white-list launchy
to the tray icons. See How do I access and enable more icons to be in the system tray?.
Also you need to add it to the Start Up applications, as it won't work when it is not opened.
After all, As an alternative for Launcy, try Synapse for its best integration with gnome and unity.
Solution 4
This is basically a modification of the answer provided at https://askubuntu.com/a/223674/22073.
You can also modify the behavior of Caps Lock using an XKBOption
. These changes are even propogated to the virtual consoles (/dev/tty[1-6], or Ctrl-Alt-F[1-6]).
For instance, to disable Caps Lock, you would have the following in /etc/default/keyboard
:
# Check /usr/share/doc/keyboard-configuration/README.Debian for
# documentation on what to do after having modified this file.
# The following variables describe your keyboard and can have the same
# values as the XkbModel, XkbLayout, XkbVariant and XkbOptions options
# in /etc/X11/xorg.conf.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:none"
# If you don't want to use the XKB layout on the console, you can
# specify an alternative keymap. Make sure it will be accessible
# before /usr is mounted.
# KMAP=/etc/console-setup/defkeymap.kmap.gz
Then you would run:
sudo dpkg-reconfigure keyboard-configuration
For a full list of the customizations of XKBOPTIONS, take a look at /usr/share/X11/xkb/rules/base.lst
. Here's the full list from my Ubuntu 13.10 machine: http://sprunge.us/cUZO
Even more information can be found on the ArchLinux wiki: https://wiki.archlinux.org/index.php/Keyboard_Configuration_in_Xorg
Solution 5
To remap the useless caps_lock into a basic shift, do
xmodmap -e "keycode 66 = Shift_L"
Related videos on Youtube
user541686
Updated on September 18, 2022Comments
-
user541686 almost 2 years
In the the past I used to use
xmodmap
to prevent the Caps Lock button from working, and then tell Launchy to handle the key press instead. I can't seem to do this anymore.What is the best way to disable Caps Lock's normal behavior, and make it do something else?
-
Léo Léopold Hertz 준영 over 8 yearsFor Ubuntu 14.04, see askubuntu.com/q/444714/25388
-
-
Jjed over 11 years@JacobJohanEdwards Note to self, check whether
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
still works. -
rpattabi over 11 yearsFor vim users, 'Practical Vim' recommends to map the caps lock to ctrl at the system level. Keyboard Layout > Options > Ctrl Key Position > Caps Lock as Ctrl does the trick.
-
Czarek Tomczak over 10 yearsThis does not persist after restart.
-
Czarek Tomczak over 10 yearsTo make it persist after restart do: Ubuntu Dash Home > Startup Applications > Add > Type the command above.
-
pcworld over 10 yearsThese settings don't exist anymore in 13.10. Install
gnome-tweak-tool
, there you will have similar settings under "Typing". -
Vitaly Zdanevich about 10 yearsAfter few minutes settings go back - and again Caps Lock have usual behaviour.
-
Andrew Wagner about 10 yearsThis is not working for me in Ubuntu 12.10. Messing with those settings in the gnome-control center don't seem to have any effect.
-
nysse over 9 yearsThis does not help with a laptop.
-
MichielB over 8 yearsThis option does not seem to be available to me on Ubuntu 15.04.
-
Andrzej Rehmann over 8 yearslove you man, thanks , it works for ubutnu 14.10
-
Léo Léopold Hertz 준영 over 8 yearsWhy did they remove these options from 14.04?
-
chepyle about 8 yearsnice and simple, works in 16.04
-
landroni almost 8 yearsTo restore any
setxkbmap
changes (i.e. if you need your Caps key back to its original location) one only needs to run this:setxkbmap -option
-
Gabriel over 7 yearsIf you remaped the Capslock key to backspace and now you wonder why it won't delete words if you keep it pressed, it's because you need to use an extra command. After
setxkbmap -option caps:backspace
enterxset r 66
and voilá. -
Pouya Sanooei about 7 yearswhat if I want to remap right alt to escape? alt:escape doesn't work
-
Márcio almost 7 yearsPerfect, I'm using
XKBOPTIONS="ctrl:swapcaps"
to swap the Left Ctrl with Caps. -
jfs almost 7 yearsIt works on 16.04 in X and the virtual consoles.
-
Alex Reinking about 5 yearshow would I remap caps to the spacebar?
-
artu-hnrq over 4 yearsIt also works at 18.04 LTS Bionic Beaver! Nice solution
-
George Mogilevsky over 4 yearsthis is the best answer i've seen! oh and did i mention that it works?! upvote!
-
Waldir Leoncio almost 4 yearsTo see a list of available options, try
less /usr/share/X11/xkb/rules/base.lst
(Ubuntu 18.04; the location ofbase.lst
might change on your system). -
Adalbert Hanßen over 3 yearsI have installed an autostart script which disables Caps Lock. However after returning from a suspend (=sleep) state, the Caps Lock key becomes operational again (at least in Xubuntu 18.04). Any Idea how to also plug this script into waking up after returning from the sleep state?
-
Mikko Rantalainen about 3 yearsI would suggest doing
xmodmap -e "keycode 66 = Shift_L Caps_Lock"
instead so that you can still access the normal caps lock using key combinationShift
+Caps lock
if needed. For other purposes, the caps lock key behaves as additional left shift.