21 October 2004 30 comments Linux
I never use the Caps Lock button. Never. The only time I "use" it is when I accidently press it and start typing things in UPPERCASE. To disable it in Linux all you have to do is enter this on the command line:
$ xmodmap -e "remove lock = Caps_Lock"
To set this permanently, just stick the above line in your ~/.bashrc
file (or /etc/bash.bashrc
if you're root) so that it looks something like this:
if [ "$PS1" ]; then
# Disables the bloody CapsLock button
xmodmap -e "remove lock = Caps_Lock"
...
fi
xmodmap -e "keycode 79 = KP_7 KP_7"
This doesn't disable the Num_Lock, but it doesn't matter.
Use "xmodmap -pke" first, to check which keycodes are relevant.
xmodmap -e "remove lock = Caps_Lock"
xmodmap -e "add shift = Caps_Lock"
I've linked to this page from my homepage:
http://home.tiscali.nl/cedric/Linux/Software/linux-trics/linuxtricsindex.html
... As I used to remove the caps lock keys on my keyboards !
I can now restaure them to their original places !
Alternatively, for the vi/vim users, turn your Caps Lock into an Escape key. Now you can switch modes without any stretching off the home row.
Add the following to ~/.Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
and the following to ~/.bashrc
if [ "$PS1" ]; then
xmodmap ~/.Xmodmap
...
fi
Option "XkbOptions" "ctrl:swapcaps"
inside Section "InputDevice" of your xorg.conf
I am xmodmap aware, but KDE supercedes XModmap modifications, and I would never haved found these options by myself.
You made my day :-)
@kalpesh: maybe not exactly the answer you are looking for but I believe it's "yes, you can". No HowTo provided here, though... But combining "man xmodmap" and xev, you can probably do miracles with your keyboard ;-)
and was happy to find your excellent tip, which has worked well so far. But on my new Installation, whenever i open a new terminal (Ctrl-Alt-T) from an open xterm, i get a message like the following in the new window
xmodmap: please release the following keys within 2 seconds:
Control_L (keysym 0xffe3, keycode 37)
Shift_L (keysym 0xffe1, keycode 50)
before the fist prompt appears (BTW; i hadn't pressed any of those keys). This message does not appear when xterm is started from the menu. When i remove the xmodmap-command, this message does not occur. Does anybody know what this means?
The problem "please release the following keys within 2 seconds:" happens when the xmodmap command is executed while the keys are held down. By adding the commands to ~/.bashrc, they are executed each time a terminal is opened, causing this error to appear each time.
In fact, you only want to run the xmodmap command once, when you log in. So, add it to ~/.bash_profile or ~/.profile instead (these are only run once)! Also make sure you don't include .profile from .bashrc (which I unfortunately did and spent much time figuring out...)
I get
t (keysym 0x74, keycode 28)
as well.
I don't know the answer yet, but it's clear what's going on.