I would like to have a key that executes a ‘controlled reset’, i.e. it should clear any active modifier (OneShot awaiting timeout or sticky) and turn off any higher layer, activating the first layer (qwerty or equivalent).
This because the keyboard is mounted under the table and I cannot see the LEDs of the modifier keys…
I first thought that it would be good if Escape-OneShot removed the sticky modifiers, but it is probably not good in every case to send Esc to the active application only to reset the keyboard to a defined state.
Thus I bound a macro to an unused key
case MACRO_TO_L0:
Layer.off(L3);
Layer.off(L4);
Layer.off(FUNCTION);
Layer.off(NUMPAD);
break;
The macro seems to clear active modifiers (those awaiting timeout) and to put the keyboard into the first layer.
Unfortunately sticky modifiers are unaffected (neither OSM, nor OSL).
What is missing here?
I found out that a sticky OSL is not cancelled by the macro if the modifier key itself was not the last key pressed immediately before my macro key.
(e.g.: double tap the modifier that locks the layer for cursor movement, move cursor, tap macro key to cancel stickies → does not work)
Injecting an additional modifier tap before actually cancelling all sticky modifiers worked for me (though probably not a very elegant way…)
OneShot.inject(OSM(LeftShift), keyState);
if (keyToggledOn(keyState)) {
OneShot.cancel(true);
}