How do I make the Caps Lock key a third Shift key?

Expanding on @Zacharee1 answer:

make a backup with cp /usr/share/X11/xkb/symbols/pc ~/pckeybak

then edit with gksu gedit /usr/share/X11/xkb/symbols/pc or your favorite editor.

Find the line (22) that says:

key <CAPS> { [ Caps_Lock ] };

and change it to

key <CAPS> { [ Shift_L ] };

and the line (36) that says:

modifier_map Lock { Caps_Lock };

and change it to

//modifier_map Lock { Caps_Lock }; (which should comment it out in effect disabling the locking)

Testing indicates that the Num Lock still works as expected. Further testing indicates that the keyboard indicator lights appear to be a bit dyslexic in 16.04 on even an unmodified system. Scroll Lock indicator on at login but Scroll lock off and Num Lock light off, but Num lock on. Tapping the left Ctrl key seems to resolve this behaviour and I'm not sure if it's related to my use of a KVM switch (which is possible)

Note: Further testing shows that the NumLock indicator light is flaky even without a KVM switch and has to be tapped twice to get back in sync with NumLock If you always leave it on you can ignore the light or if it bothers you you can tap it twice to get it back in sync. Why this occurs is likely a basis for a new question...

Another simple solution to your original problem would be to simply obtain an inexpensive US keyboard and use the US keyboard mapping.

Sources: @Zacharee1 answer and analysis of /usr/share/X11/xkb/symbols/pc and trial and error testing


You can get there by adapting How to change CapsLock key to produce “a”? (for example).

Remove the Lock (= Caps Lock) modifier from the Caps Lock key, and declare that this key sends the Shift_L keysym.

remove Lock = Caps_Lock
keysym Caps_Lock = Shift_L

Alternatively, you could remove the Lock modifier and add the Shift modifier.

remove Lock = Caps_Lock
add Shift = Caps_Lock

Either way, these lines go into the file ~/.Xmodmap. Test by loading it with xmodmap ~/.Xmodmap; the file is read automatically when you log in under the default environment (or at least it was in the Gnome days).


Ignoring my previous attempts at answering that failed, I found something that turns capslock completely into left shift. No toggling, I think it's persistent, and it's pretty simple.

First, I'd recommend making a backup, before I introduce how to change it.

Run sudo cp /usr/share/X11/xkb/symbols/pc ~/pckeybak

Now that there's a backup, let's get to the editing.

Use your favorite text editor to edit this file as root:

/usr/share/X11/xkb/symbols/pc

Find the segment that looks like this (it's near the top, line 22 for me):

key  <TAB> {    [ Tab,  ISO_Left_Tab    ]   };
key <RTRN> {    [ Return                ]   };

key <CAPS> {    [ Caps_lock             ]   };
key <NMLK> {    [ Num_Lock              ]   };

edit

key <CAPS>  {   [ Caps_lock             ]   };

to be

key <CAPS> {    [ Shift_L, Caps_Lock    ]   };

instead. (The Caps_Lock after Shift_L, may be unnecessary.)

Restart your display manager (usually sudo service lightdm restart) and capslock will now be left shift. (Note: My test machine uses GNOME, so I had to restart gdm. However, that caused some weird flickering in the fallback TTY, and gdm never restarted. I had to completely reboot.)

This one I was actually able to test, and can confirm it works.

Adapted from Permanent xmodmap in Ubuntu 13.04