Ubuntu – Disable Sticky Keys’ “Locked After Being Successively Pressed Twice” Behavior


I enabled sticky keys for ergonomics' sake. The default behavior under Unity and GNOME 3 is that a modifier (or layer) key will be "locked" after being pressed twice successively, and a third press will release the key. Sometimes I accidentally locked my Shift-key such that all the characters being typed thereafter are capitalized. This has been especially frustrating under a password prompt where the input isn't shown, hence I'm would like to disable this behavior.

After some Googling, it appears that Windows' StickyKeys has a "Press modifier key twice to lock" option. I tried looking for corresponding dconf keys, but to no avail. The closest I've come across is "Behavior of sticky keys":

Controls the behavior of sticky keys, e.g. modifier and layer keys.

Groups of keys or single keys may be assigned individual behaviors.

Valid groups are 'all', 'modifiers' and 'layers'. Individual keys may
be specified by their ids defined in the .layout files.

Valid behaviors are: 'cycle' (default), 'dblclick', 'latch', 'lock' as well
as 'latch-lock-nocycle', 'dblclick-nocycle', 'latch-nocycle',
'lock-nocycle' and 'push'.

I tried all the "behaviors" (namely: 'cycle' (default), 'dblclick', 'latch', 'lock' as well as 'latch-lock-nocycle', 'dblclick-nocycle', 'latch-nocycle', 'lock-nocycle' and 'push'), yet the default behavior remains.


Ubuntu 16.04.1


Best Answer

I had the exact same issue for a long time.

You can get the behavior you want by using xkbset. You can install it using apt.

sudo apt install xkbset

You can see the available options with

 xkbset -h

So instead of enabling sticky keys through the GUI. Use xkbset. The command given by another question worked for me. Specifically the -latchlock option disables the unwanted behavior.

Currently I use

 xkbset exp -bell -sticky -twokey -latchlock -accessx -feedback -stickybeep -led 9999
 xkbset bell sticky -twokey -latchlock feedback led stickybeep

It seems like restarting your computer will forget the settings. Adding them as a startup script will work.