15

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

2
  • What is "sticky keys"? Apr 10, 2012 at 7: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, 2012 at 7:43

4 Answers 4

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

 

7
  • 1
    Here is a link to xkbset: math.missouri.edu/~stephen/software/#xkbset
    – user193100
    Apr 4, 2013 at 23:11
  • This is available in debian in the package xkbset. Jun 1, 2014 at 8:40
  • 3
    This answer is very helpful! Now I just want to find a way to limit the sticky behavior to the Shift keys. Jun 1, 2014 at 22:34
  • 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. github.com/hallettj/dot-xmonad/blob/master/home/.config/X11/xkb/… Nov 15, 2019 at 17:17
  • 1
    @JesseHallett thank you for the pointer! I will try this out asap.
    – bhootjb
    Nov 16, 2019 at 3:20
6
+50

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.

2
  • 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, 2012 at 21:37
  • XKB is a better way to do this. Check Arch wiki Jun 1, 2014 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
-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.

1
  • Mmm... I would really like to have this without having to resort to Gnome or XFCE... bummer!
    – Macario
    Apr 16, 2012 at 5:22

You must log in to answer this question.

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