I want to map one of my keys the shift lock key. In my understanding, the shift lock key is a kind of a 'sticky' shift key: it remains pressed, shifting all keys of the layout until pressed again.

It is similar to the Caps Lock key, except that it affects all keys, including the ones in the numeric row.

I am trying to use setxkbmap -option ... to handle this.

I found these promising rules in in /usr/local/share/X11/xkb/rules/base.lst:

  caps:internal        Caps Lock uses internal capitalization; Shift "pauses" Caps Lock
  caps:internal_nocancel Caps Lock uses internal capitalization; Shift doesn't affect Caps Lock
  caps:shift           Caps Lock acts as Shift with locking; Shift "pauses" Caps Lock
  caps:shift_nocancel  Caps Lock acts as Shift with locking; Shift doesn't affect Caps Lock
  caps:capslock        Caps Lock toggles normal capitalization of alphabetic characters
  caps:shiftlock       Caps Lock toggles ShiftLock (affects all keys)
  shift:breaks_caps    Shift cancels Caps Lock
  shift:both_capslock  Both Shift keys together toggle Caps Lock
  shift:both_capslock_cancel Both Shift keys together activate Caps Lock, one Shift key deactivates
  shift:both_shiftlock Both Shift keys together toggle ShiftLock


setxkbmap -option shift:both_shiftlock

And I try pressing Shift (and releasing it), and typing other characters. No effect. All characters lowercase. If I hold down Shift and type other keys, it acts as you'd normally expect.

I tried caps:shift, shift:both_shiftlock and caps:shiftlock but none of them have any effect as far as I can tell. What's wrong?

  • Oh, I didn't realise it read Both Shift keys together. So shift:both_shiftlock works, but that's no good since those two keys are terribly far away from each other.
    – oals
    Aug 22, 2015 at 19:20
  • Okay, it seems my ctrl:swapcaps is one problem. swapcaps and shiftlock don't play well together at all.
    – oals
    Aug 22, 2015 at 19:25
  • So: caps:shiftlock works but only if caps lock is left of the 'A' key, not left of the space bar. Sigh.
    – oals
    Aug 22, 2015 at 19:35

1 Answer 1


I found a way to turn Caps Lock into Shift Lock, thanks to a Super User answer:

xmodmap -e "keycode 66 = Shift_Lock"

The following turns my left Ctrl key into shift lock:

xmodmap -e "keycode 37 = Shift_Lock"

To make the left Shift key lock, use

xmodmap -e "keycode 50 = Shift_Lock"

Right Shift key, use

xmodmap -e "keycode 62 = Shift_Lock"

When Shift Lock is active, your keyboard's Caps Lock and Scroll Lock LEDs should both be lit.

  • In that case please edit your question title to reflect the answer (and re-tag it xmodmap) as otherwise the obvious answer is to use the shift:both_shiftlock Aug 22, 2015 at 20:08
  • @don_crissti I'm confused. The question and its title match my answer -- the only difference is the tool used. setxkbmap apparently does not have the capability to get sticky shift keys except in two specific configurations.
    – oals
    Aug 22, 2015 at 21:10
  • Well, ... the title says : "How do I enable Shift Lock? (Sticky shift key)" and the answer is "use setxkbmap with shift:both_shiftlock" though what you actually want is to shiftlock with a custom key (or custom key combo) Aug 22, 2015 at 21:25
  • @don_crissti All I asked was how to get Shift Lock working -- any method. To me, the most desirable/familiar method is a sticky Shift key. You may write a second answer about setxkbmap if you think it improves this question. (I think it does.)
    – oals
    Aug 22, 2015 at 21:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .