Ubuntu – How to change CapsLock key to produce “a”


While typing I often hit the CapsLock key instead of the a key. (QWERTZU keyboard)
This is quite annoying because the moment I realise that I hit the wrong key, I will have to delete multiple character/lines of text an rewrite them in the right form.

I am searching for a way to prevent this.

I have found a possibility to disable the CapsLock key in Keyboard Layout Options. But this would in my case mean that instead of writing an a I would write nothing.

Positive -> I don't have to rewrite a whole line, but only one character

Negative -> It's not that obvious that I hit the wrong key, as a missing character is not perceivable as an upper-case line of text.

I would therefore prefer a possibility to map CapsLock to a . Thus when hitting CapsLock an a character would be written.

Positive -> If I hit CapsLock instead of a I get the output I actually wanted to type.

Negative -> If I hit CapsLock in any other context I will get an a character. As I don't ever intentionally use the CapsLock key this would not really pose a problem. (I think, or does it?)

My Question:

  1. So how do I change to a ?
  2. And is there any case where this could be dangerous/provoke unwanted behaviour?

Best Answer

Specifically, I don't know how to change CapsLock to a, because I don't remember the keycode. I'll find it a little later. But generally speaking, you can use xmodmap (and .Xmodmap) to change your keymappings. The first time GNOME detects your .Xmodmap file, it'll ask if you want to always load it, and then you're set.

I also think caps lock is silly. However, the key position is useful. I like mapping it to the Control key. I use control a lot, and it's tiring for my pinky to be constantly reaching down in that awkward position. And as I later found, historically Control is where Caps Lock is currently. Anyway. Create a file in your home directory called .Xmodmap with the following lines:

remove Lock = Caps_Lock
keysym Caps_Lock = Control_L

To make these changes take effect right this instant, run xmodmap ~/.Xmodmap.

You can find keycodes on your own using xev. Turns out the keycode for a is 38, or hex 0x61. So instead your .Xmodmap could be:

remove Lock = Caps_Lock
keysym Caps_Lock = 0x61

I highly recommend reading through the man page, lots of interesting stuff.

Related Question