The very concept of the Caps Lock key is aggravating to me. Obviously such a useless function should not have its own key and certainly not a key so easy to type. Once you get used to having a control key just to the left of the "A", your arthritis will be cured, you’ll be able to bowl a perfect game, your life will be a joyous celebration, and you will no longer be able to use uncorrected keyboards.

This Emacs wiki page is an unusually competent resource on the topic of fixing the Caps Lock menace. Of course Emacs would really be especially awful with the Control key in the wrong place.

Consoles

Consoles are the seriously text only screens that you can often get to (under Linux) with something like CTRL-ALT-F2. (CTRL-ALT-F7 or CTRL-ALT-F1 usually brings you back to your graphical session). These can be very useful for troubleshooting broken graphics drivers or for using the computer at all if it is a non-graphical server whose network is down.

Unfortunately the GUI settings menus of various window managers (Gnome, KDE, et al) tend to not touch the console settings at all. The way to really deeply cure caplockitis on the consoles is to edit the keyboard mappings.

vi /usr/share/keymaps/i386/qwerty/us.map.gz

Change keycode 58 from "Caps_Lock" to "Control".

Make this take effect.

loadkeys us

Ah, that’s better.

Also for the console fix in Gentoo, you might be able to get away with editing /etc/conf.d/keymaps and adding KEYMAP="emacs" and then /etc/init.d/keymaps restart.

Debian Consoles

Go to System→Preferences→Keyboard→Layouts→Options→Ctrl key position Check "Caps Lock as Ctrl".

Amazingly the virtual console can also be cured with minimal fuss.

sudo sed -i 's@\(XKBOPTIONS="\)@\1ctrl:nocaps@' /etc/default/keyboard
sudo dpkg-reconfigure -phigh console-setup

Takes effect after the next reboot.

General X Windows Systems

In graphical environments, it used to be something like editing /etc/X11/xorg.conf and adding a Option "XkbOptions" "ctrl:nocaps" line. But this is not likely to work reliably today. Now there are all kinds of approaches but the one that seems to still do anything is setxkbmap.

You can check how things are set up using setxkbmap -print and looking at the xkb_symbols field.

To actually try to change the Caps Lock to a Control do something like this.

setxkbmap -option -option 'ctrl:nocaps'

Note that specifying the -option (single dash long option… ahem) twice is necessary because if there is some other messy setting in there, it appends the new one by default without the argumentless option first.

setxkbmap -option 'caps:ctrl_modifier'

xkbcomp

Why this is so absurdly complex is hinted at in this 2013 comment by Bogdan in the link I provided above. I’ll quote the whole thing because it’s so interesting.

On a modern Linux like Ubuntu Precise it is actually /usr/share/X11/xkb/rules/evdev.lst that’s being used by setxkbmap. base.lst is another one of these paste-and-rape decoy files.

I should also point out that ‘setxkbmap […] -print’ creates stanzas ready for feeding to xkbcomp, and for me these stanzas were not harder to understand than setxkbmap command line options. I ended up not using setxkbmap at all because it seemed like obfuscation rather than abstraction in the end, and http://madduck.net/docs/extending-xkb/ came to the same conclusion.

I think the main virtue of this setxkbmap spaghetti is the evdev.xml file which was probably meant for some GUI keyboard configurator wallpaper to parse, but I’m being speculative. Anyway I think humans should create an example stanza with ‘setxkbmap […sane options…] -print’, edit that file, and invoke ‘xkbcomp $DISPLAY’ from xinitrc or Xsession or .config/autostart or whatever you use to twiddle new sessions.

Note the link he cites as it is truly a revelation and worth a read to the serious capslock hater.

Gnome

In Gnome situations, there are often cryptic poorly organized hidden settings to fix caps locks. Looks like in Gnome 3 they removed all useful functionality including the ability to get rid of the capslock function in an obvious way. I found that the setxkbmap was my only recourse (any behind the scenes technique will probably work).

Here you can find some images of the correct menus which will help you find these sneaky settings.

Macs

Go to System PreferencesKeyboard and choose Modifier Keys. Select the "Caps Lock" labeled selection box and choose "Control". Bravo to Mac for having a system here that is in no way nonsensical (except for having the Caps Lock to begin with).

Other Keyboard Tricks

Maybe you have some offensive logos on some keys on your computer that you have scraped off and are now wondering what to do with them. Maybe you even have an odd keyboard with a "Win-Lock" lit key. What is that? Well, the way to find out is with xev.

Mouse Issues

This is a little off topic but mice often have similar problems as capslock, basically having your IO devices not behave intelligently.

Middle Mouse Button

A common problem is how to make a two button trackball produce a middle click?

xinput list
xinput list-props $DEV_ID

Look for this.

Evdev Middle Button Emulation (276):    1

If the property is not active (i.e. "1"), set it.

xinput --set-prop $DEV_ID "Evdev Middle Button Emulation" 1

When active, both buttons together send the middle button event. I notice this can even be active when there is a middle button. This can be useful for pasting without scrolling if the middle button is also the scroll wheel.

Mouse Sensitivity

Here’s how to adjust the mouse sensitivity.

xinput set-prop $DEV_ID "Device Accel Constant Deceleration" 2