Branch
Hash :
ee50e0c9
Author :
Date :
2025-06-12T20:14:50
keymap: Add option `unlockOnPress` for LockMods()
It enables e.g. to deactivate CapsLock on press rather than
on release, as in other platforms such as Windows.
The specification of `LockMods()` is changed to:
- On key *press*:
- If `unlockOnPress` is true and some of the target modifiers were
*locked* before the key press, then unlock them if `noUnlock` false.
- Otherwise:
- add target modifiers to *depressed* modifiers;
- if `noLock` is false, add target modifiers to the *locked*
modifiers.
- On key *release*:
- If `unlockOnPress` is true and triggered unlocking on key press, do
nothing.
- Otherwise:
- remove modifiers from the *depressed* modifiers, if no
other key that affect the same modifiers is down;
- if `noUnlock` is false and if any target modifiers was locked before
the key press, *unlock* them.
It fixes a [12-year old issue] inherited from the X11 ecosystem,
by extending the [XKB protocol key actions].
As it is incompatible with X11, this feature is available only using the keymap
text format v2.
[12-year old issue]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/312
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
partial xkb_compatibility "caps_lock" {
// Keysym Caps_Lock locks the Lock modifier.
// With this definition, the keysym Caps_Lock can be used without binding
// the whole key to a real modifier. This is essential when you don't
// want to use Caps_Lock on the first level.
// This should not have any compatibility issues when used together with
// other layouts which don't utilize this capability.
interpret Caps_Lock {
action = LockMods(modifiers = Lock);
};
};
partial xkb_compatibility "unlock-on-release" {
interpret Caps_Lock {
action = LockMods(modifiers = Lock, unlockOnPress=false);
};
interpret.repeat= False;
interpret Caps_Lock + Lock {
action = LockMods(modifiers = Lock, unlockOnPress=false);
};
};
partial xkb_compatibility "unlock-on-press" {
interpret Caps_Lock {
action = LockMods(modifiers = Lock, unlockOnPress);
};
interpret.repeat= False;
interpret Caps_Lock + Lock {
action = LockMods(modifiers = Lock, unlockOnPress);
};
};