# Ubuntu – remap Caps + L to dash

gnomekeyboardkeyboard-layoutshortcut-keys

I want to remap the four keys ()-= to Caps+jkl; respectively.
The idea is to not leave the home row for typing these characters which are very common in programming.

This includes pressing Caps Shift l to produce _, which is the equivalent of Shift -

I also want Caps to act as ESC when pressed on it's own.

1. https://github.com/simos/keyboardlayouteditor – Installation has syntax error
2. https://www.bedroomlan.org/projects/evrouter/ – No support for multi keys
3. editing /usr/share/X11/xkb/symbols/pc – I don't see an option for combinations, and couldnn't figure it out from the docs
4. evdevremapkeys – no support as described in this issue
5. xdotool – works but it's very slow …
6. Mapping directly in vim – that would be my fallback, tho I want this available system-wide

Any help appreciated, probably some guidance would be enough for me to crack this one.

Thanks!

Work Around

Warning: editing the file /usr/share/X11/xkb/symbols/us is very risky if any small typo mistakes occur.. it leads to login loop.. Proceed only if you can manage things from tty in such case..

1. change directory to /usr/share/X11/xkb/symbols/

run command:

cd /usr/share/X11/xkb/symbols/

1. take backup of us file

run command:

sudo cp us usbackup

1. edit the file us

run command:

sudo -H gedit us

1. Edit the lines like below

Content:

key <AC01> {    [     a,    A       ]   };
key <AC02> {    [     s,    S       ]   };
key <AC03> {    [     d,    D       ]   };
key <AC04> {    [     f,    F       ]   };
key <AC05> {    [     g,    G       ]   };
key <AC06> {    [     h,    H       ]   };
key <AC07> {    [     j,    J,  parenleft           ]   };
key <AC08> {    [     k,    K,  parenright          ]   };
key <AC09> {    [     l,    L,  minus, underscore   ]   };
key <AC10> {    [ semicolon,    colon,  equal,  plus]   };
key <AC11> {    [ apostrophe,   quotedbl            ]   };

1. Save the file and Close.

2. gnome-shell refresh with Alt+F2rEnter or Logout & Login may be required..not tested..

3. make Caps_Lock as the level3 modifier with the below command

run command:

gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:caps_switch']"


with the above command the Caps_Lock modifier changed to ISO_Level3_Shift which will print the 3rd keysym from the edited us file while Caps_Lock is held down.. similarly 4th keysym if Caps_Lock & Shift are held down..

1. Now to make the modifier ISO_Level3_Shift to behave on its own while pressed and released.. use the great tool xcape..

run command:

sudo apt install xcape


Description: Configure modifier keys to act as other keys when pressed and released xcape allows you to use a modifier key as another key when pressed and released on its own. Note that it is slightly slower than pressing the original key, because the pressed event does not occur until the key is released. The default behaviour is to generate the Escape key when Left Control is pressed and released on its own.

1. once xcape is installed run the below command to make Caps_Lock behave as Escape when it is pressed and released..

run command:

xcape -e 'ISO_Level3_Shift=Escape'

1. Add the above command in your startup applications preference list so that no need to run the command on every login/ boot..

thats it.. You are Done..

with the Caps_Lock Modifier all the 4 things ( ) - = and with Caps_Lock+Shift Modifiers _ are achieved..

When only Caps_Lock is pressed and released.. It acted as Escape as that is how we configured.