Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?
share|improve this question
3  
How did you get CapsLock and a to look all fancy and button like? –  djeikyb Jan 27 '11 at 9:30
    
fluteflute edited my question to make them look like that, but I would be interested in that too. –  Pit Jan 27 '11 at 9:42
5  
You write <kbd>a</kbd> (it only works in questions & answers, not comments) –  8128 Jan 27 '11 at 10:05

2 Answers 2

up vote 18 down vote accepted

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.

share|improve this answer
    
Do I only need to use the last to lines you posted? I get the following error: xmodmap: /home/pit/.Xmodmap:1: bad keysym in remove modifier list 'Caps_Lock', no corresponding keycodes xmodmap: /home/pit/.Xmodmap:2: bad keysym target keysym 'Caps_Lock', no corresponding keycodes xmodmap: 2 errors encountered, aborting. I did not see anything in the manpage that explains this behaviour. I also tried to run the the command as sudo but it did not change the errors. –  Pit Jan 27 '11 at 10:10
2  
Lol, I still had the CapsLock key disabled from my previous test in Keyboard Layout Options. After re-enabling it, it works. Thanks. –  Pit Jan 27 '11 at 10:15
    
Just a note: I used this guide to get caps lock to map to control, but I had to insert add Control = Caps_Lock in between the remove and the keysym lines to get it to work. –  Bryan Head Jun 28 '12 at 16:53

After looking at man xmodmap, it turns out there is an idempotent way to define this:

clear Lock
keysym Caps_Lock = Caps_Lock Control_L

After restarting X, you should be able to run xmodmap ~/.Xmodmap repeatedly without getting any "bad keysym" errors.

Update: Unfortunately this doesn't seem to be portable and idempotent.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.