15

I would like to enable "sticky modifier keys" under archlinux + awesome, and I haven't found the correct info.

Macario
  • 478
  • 4
  • 15
  • What is "sticky keys"? – Daniel Andersson Apr 10 '12 at 07:31
  • right, I meant "sticky modifier keys", it means that pressing a modifier key acts as a toggle and usually the toggle is released on the next key press, so keys don't have to be pressed simultaneously but can be pressed in sequence. This is an accesibility for disabled users feature on OS-X, Gnome and probably Windows, and I find it more confortable and less hand straining with the feature on. – Macario Apr 10 '12 at 07:43

4 Answers4

26

I've got it. There is a utility called xbkeys for setting accessibiltiy options for xorg.

From xkbset manual ($ xkbset man):

To switch sticky keys on or off, and optionally set or reset:
() two keys pressed at the same time stops sticky keys;
() a modifier pressed twice will be locked:

    [-]{sticky|st} [[-]twokey|[-]latchlock]...

I ran this:

$ xkbset sticky -twokey -latchlock

That command can go in .xinitrc

# turn on stickykeys. don't let two keys pressed at the same time disable it.
# don't turn on "latch lock", ie pressing a modifier key twice "locks" it on.
xkbset accessx sticky -twokey -latchlock

# don't expire these settings. (run xkbset q exp for details.)
xkbset exp 1 =accessx =sticky =twokey =latchlock

 

U Aberg
  • 3
  • 2
Macario
  • 478
  • 4
  • 15
  • 1
    Here is a link to `xkbset`: http://www.math.missouri.edu/~stephen/software/#xkbset –  Apr 04 '13 at 23:11
  • This is available in debian in the package `xkbset`. – Jesse Hallett Jun 01 '14 at 08:40
  • 3
    This answer is very helpful! Now I just want to find a way to limit the sticky behavior to the Shift keys. – Jesse Hallett Jun 01 '14 at 22:34
  • @JesseHallett Did you find a way to limit the sticky behaviour? – bhootjb Nov 14 '19 at 11:20
  • 2
    @JayeshBhoot Yes; xkb has "latch" variants of some keys. I get sticky shift by mapping my shift keys to `ISO_Level2_Latch` which acts like shift for modifier purposes. (Some programs that look for the shift keycode specifically don't work with `ISO_Level2`, especially games.) I have my config online; but you'll need to look up some documentation on the specific details of applying custom key mappings. https://github.com/hallettj/dot-xmonad/blob/master/home/.config/X11/xkb/symbols/hallettj – Jesse Hallett Nov 15 '19 at 17:17
  • 1
    @JesseHallett thank you for the pointer! I will try this out asap. – bhootjb Nov 16 '19 at 03:20
  • There's a lovely bug in GNOME lately where booting up with X leaves sticky keys off even though the accessibility menu shows them as remembered on (I think this doesn't happen with Wayland, but Wayland has a profoundly brain-damaged implementation of sticky keys which is approximately unusable unless you're literally only ever hitting one modifier key at a time, as opposed to using sticky keys to have that option along with multi-pressing and any/all of the other benefits of latch-to-lock modifiers) - I think `xkbset sticky -twokey latchlock` is the thing that finally lets me fix it. – mtraceur May 06 '23 at 06:19
6

You can use Xmodmap to set a key lock for the Scroll, Kana, Num, Caps, and Shift keys. Also some ISO groupings keys can be remapped this way. For example, on my keyboard, to set Left Shift as a toggle, use this:

xmodmap -e "keycode 50 = Shift_Lock"

use "xev" to get the correct keycode.

Just add the command inside the quotes to a file named .Xmodmap and restart X to have the changes permanent.

Unfortunately, I don't think there is a keycode to Lock the Control, Alt, or Meta keys. If you post a more specific question and add a decent bounty, I may be able to work out a shell script and/or xorg change to make this possible.

gogators
  • 1,303
  • 7
  • 13
  • Unfortunatelly I haven't got any more points to offer, I really am missing sticky modifiers as in cntrl, window, alt, meta... – Macario Apr 19 '12 at 21:37
  • XKB is a better way to do this. Check [Arch wiki](https://wiki.archlinux.org/index.php/X_KeyBoard_extension) – phil pirozhkov Jun 01 '14 at 23:17
2

One way to enable sticky keys is to press the StickyKeys_Enable key. If you don’t have it mapped to your keyboard you can simulate the keypress with e.g. Xdotool:

> xdotool key StickyKeys_Enable
Guildenstern
  • 134
  • 5
-1

As far as I know, Xorg doesn't support this. It's not inconceivable for a custom keyboard driver to implement this, but I have never come across such a thing.

mkaito
  • 2,032
  • 1
  • 14
  • 17