1

I want to bind CapsLock + hjkl to arrow keys, I found two way that each have some issues:

Solution 1

Using xkb : Edit /usr/share/X11/xkb/symbols/us first block.

            # replace Caps with AltGr
            key <CAPS> { [ ISO_Level3_Shift            ] };
            # Add vim cursor keys to be accessed with AltGr
            key <AB02> { [ x, X, Delete, Delete        ] };
            key <AC02> { [ s, S, KP_Enter, KP_Enter    ] };
            key <AC03> { [ d, D, Next, Next            ] };
            key <AC04> { [ f, F, BackSpace, BackSpace  ] };
            key <AC06> { [ h, H , Left, Left           ] };
            key <AC07> { [ j, J, Down, Down            ] };
            key <AC08> { [ k, K, Up, Up                ] };
            key <AC09> { [ l, L, Right, Right          ] };
            key <AD07> { [ u, U, Prior, Prior          ] };
            key <AE03> { [ 3, section, Home, Home      ] };
            key <AE04> { [ 4, dollar, End, End         ] };

but this answer don't work in java programs (e.g IntelliJ), so I should using solution two.

Solution 2
Using xmodmap: Create ~/.xmodmap file with following content:

keycode 66 = Mode_switch
keysym h = h H Left
keysym l = l L Right
keysym k = k K Up
keysym j = j J Down
keysym u = u U Prior
keysym i = i I Home
keysym o = o O End
keysym p = p P Next

and then run xmodmap ~/.xmodmap command.

Problem: This solution breaks other layouts. It works in English, but when I switch other layout, e.g. to Russian I cannot type letters on these keys and caps + hjkl also doesn't work until I switch back to English. How can I solve this problem?

  • Other options might be to look into keynav, or get a programmable keyboard like en ergodox-ez. – Henrik Aug 1 at 9:33
  • @Henrik But I want to bind this keys on my own laptop's keyboard – Mehran Prs Aug 1 at 13:23
  • That rules out getting a programmable keyboard, but not keynav. – Henrik Aug 2 at 8:17
  • @Henrik As far as I understand , keynav is for mouse navigation, but I want keyboard navigation to navigate between characters, Furthermore keynav need to start shortcut and then we can navigate, but i want to navigate without a start shortcut.(just same as keyboard arrow keys). – Mehran Prs Aug 2 at 17:25
0

See the example here https://wiki.archlinux.org/index.php/X_keyboard_extension#Caps_hjkl_as_vim_keys

It should work in all apps perfectly.

I will try to elaborate this answer and submit more complete example later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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