Sample Header Ad - 728x90

Bind CapsLock+hjkl to arrow keys

3 votes
2 answers
4512 views
I want to bind Caps Lock + H / J / K / L to arrow keys.  I found two ways that each have some issues: **Solution 1** Using xkb: Edit /usr/share/X11/xkb/symbols/us first block.
# replace Caps with AltGr
            key  { [ ISO_Level3_Shift            ] };
            # Add vim cursor keys to be accessed with AltGr
            key  { [ x, X, Delete, Delete        ] };
            key  { [ s, S, KP_Enter, KP_Enter    ] };
            key  { [ d, D, Next, Next            ] };
            key  { [ f, F, BackSpace, BackSpace  ] };
            key  { [ h, H , Left, Left           ] };
            key  { [ j, J, Down, Down            ] };
            key  { [ k, K, Up, Up                ] };
            key  { [ l, L, Right, Right          ] };
            key  { [ u, U, Prior, Prior          ] };
            key  { [ 3, section, Home, Home      ] };
            key  { [ 4, dollar, End, End         ] };
but this answer doesn't work in Java programs (e.g., IntelliJ), so I should use solution 2. **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 + H / J / K / L also don't work until I switch back to English. How can I solve this problem?
Asked by Mehran Prs (141 rep)
Aug 1, 2019, 08:35 AM
Last activity: Sep 1, 2023, 07:02 AM