How to enable Shift Lock? (Sticky shift key)

keyboard-layoutx11xkbxmodmap

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

So,

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?

Best Answer

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.

Related Question