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

How do I make the Caps Lock key work just like another Shift key?

There are loads of questions here about reassigning it, or having it launch a custom command. I just want it to work like another Shift key. I don’t want any other keys to change what they do, just that one.

Keyboard Layout/Caps Lock key behavior won’t do it, I don’t understand how to remap it in CCSM.

I’m using a UK keyboard now but I learned to type on a US keyboard, the smaller left Shift key is DRIVING ME NUTS.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

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

Solution 2

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).

Solution 3

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

Solution 4

For 14.04

A one-liner:

xmodmap -e 'keycode 66=Shift_L'

BUT, in the unexpected case 66 is not the correct keycode, first run xev in console and press CapsLock. Then you will see something like:

KeyPress event, serial 27, synthetic NO, window 0x1200001,
    root 0x101, subw 0x0, time 6417361, (340,373), root:(342,393),
    state 0x0, keycode XX (keysym 0x0207, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

The correct keycode is the one indicated in the XX.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply