3

I would like the right Alt key, when pressed together with h, j, k, l to work as the left, down, up, and right arrow keys respectively.

I don't need the right Alt key to work otherwise, but it would be nice if it were perhaps an Alt key. When used with Ctrl, the cursor keys should work like the usual ones. When editing text in a Firefox edit box, Ctrl+R_Alt+l should skip one word to the right.

How do I achieve this?

I have tried multiple things, but I wouldn't like to post them here because none of them worked. I have first tried implementing this in 2010, but there wasn't a lot of material back then. Looking around now, there doesn't seem to be much info about it either. My current OS is Ubuntu 18.04, 64-bit.

graham
  • 10,436
cheater
  • 173

1 Answers1

0
  • Create a new layout by opening your current keyboard layout (eg. /usr/share/X11/xkb/symbols/us) and save the file as a new file (eg. oe).
  • Inside the first block (xkb_symbols "basic") and at the end, add include "level3(ralt_switch)"

  • In that same block, locate the key symbol for h (eg. <AC06>) and change the contents so it reads something like key <AC06> { [ h, H, Left ] };

  • Open /usr/share/X11/xkb/rules/evdev.xml

  • Go to the end of the <layoutList> section (search for </layoutList>) and add the following after the last </layout> tag:

    <layout>
     <configItem>
       <name> oe </name>
       <shortDescription> oe </shortDescription>
       <description> my new keyboard layout </description>
       <languageList>
          <iso639Id> eng </iso639Id>
       </languageList>
     </configItem>
     <variantList/>
    </layout>
    
  • Repeat for corresponding key symbols(Right, Up, Down) and the other keys (j, k, l).

  • Load your newly created layout with setxkbmap -layout oe

Note : This has been tested for h and works for Ctrl+Alt+h to move cursor one word to the left.