I'm trying to get Caps Lock to generate Left and Shift+Caps Lock to generate Right. I would like other modifiers (not Shift) to be passed through unchanged.

I have a new laptop with tiny arrow keys that are hard to hit. That makes going back in the browser hard to do with the keyboard. With the remapping I'm trying to achieve, Alt+Caps Lock translates to Alt+Left, which is great. I want to be able to go forward through Alt+Shift+Caps Lock.

Here's what I've tried with setxkbmap:

default partial xkb_symbols "basic" {

    include "us(basic)"
    include "shift(both_capslock_cancel)"

    key <CAPS> { [ Left, Right ] };

This works for Left, but fails for Right. Emacs C-h c reports that I'm sending Shift+Right when I type Caps Lock+Right. Emacs handles that fine, but Chrome appears to be confused by the Shift modifier.

How can I remove the Shift modifier in this case? I've tried all kinds of variations on the above, but without success.


1 Answer 1


I figured out how to do this. I put the following in /usr/share/X11/xkb/symbols/capslockarrow and ran setxkbmap capslockarrow:

default partial xkb_symbols "basic" {

    include "us(basic)"
    include "shift(both_capslock_cancel)"

    key <CAPS> {
        type[Group1] = "TWO_LEVEL",
        symbols[Group1] = [ Left, Right ],
        actions[Group1] = [ NoAction(), RedirectKey(key=<RGHT>, clearmods=Shift) ]

Note that this also makes holding both Shift keys simultaneously act as pressing the Caps Lock key, i.e. it toggles the shift state.

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.