Skip to content

Instantly share code, notes, and snippets.

@johanwiden
Last active October 15, 2025 09:47
Show Gist options
  • Select an option

  • Save johanwiden/6fce3cb78e42405ad0b1b659bfcff53c to your computer and use it in GitHub Desktop.

Select an option

Save johanwiden/6fce3cb78e42405ad0b1b659bfcff53c to your computer and use it in GitHub Desktop.
kanata configuration for sticky modifier keys
One can use https://github.com/jtroo/kanata to remap or modify keyboard keys.
What follows is a configuration to make the modifier keys sticky.
The modifier keys are: Control keys, Shift keys, Alt keys, WinKey/Super/Meta key, Caps Lock.
They now work in two ways:
- As before one can hold down modifier keys, and tap other keys, to get e.g. Ctrl-a
- One can now also just tap modifier keys, followed by tapping an ordinary key.
- There is a timeout for how long the tap of a modifier key is valid, here configured to two seconds.
- Tapping the WinKey/Super/Meta key is usually handled specially in e.g. Ubuntu. This functionality is not lost, but is
delayed until the timeout.
Motivation: I do not have RSI problems. I just think that it is convenient, and more ergonomic, to be able to use
sticky modifier keys, while also having the old (conventional) functionality available.
I used kanata 1.10.0-prerelease-2, in Ubuntu 25.04.
Here is the config, without comments, to keep it brief. To understand the configuration better, one can have a look at the
documentation and sample configurations in the github kanata repo.
```
(defcfg
process-unmapped-keys yes
)
(defvar
os-timeout 2000
)
(defalias
oslctl (one-shot $os-timeout lctl)
osrctl (one-shot $os-timeout rctl)
oscaps (one-shot $os-timeout caps)
oslmet (one-shot $os-timeout lmet)
oslalt (one-shot $os-timeout lalt)
osralt (one-shot $os-timeout ralt)
oslsft (one-shot $os-timeout lsft)
osrsft (one-shot $os-timeout rsft)
)
(defsrc
lctl rctl caps lmet lalt ralt lsft rsft
)
(deflayer default
@oslctl @osrctl @oscaps @oslmet @oslalt @osralt @oslsft @osrsft
)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment