I’m trying to get a key to generate different strings, depending on whether shift has been pressed. This to be able to speed up typing common sequences like “th” and “Th”. I can generate these strings, but the interaction with OneShot modifiers surprised me.
If I hit a key that triggers a macro the oneshot modifier remains active until I hit the next key that does not contain a macro. This also happens with the anykey macro that is in the default firmware, so I assume this is expected behavior. Unfortunately it evades me how to get the behavior I want to prevent the next key having shift applied.
Can anyone give me a hint how I can adapt the macro below to ensure that it does indeed deactivate the modifier. The first attempt at the macro I put together is below (it would be more ideal to have a function I can feed shifted/unshifted strings to, but this at least got me close to what I want).
case MACRO_TH:
if (keyToggledOn(keyState)) {
if ( wasShiftActive() ) {
return Macros.type(PSTR(“Th”));
} else {
return Macros.type(PSTR(“th”));
}
}
break;
in which I have used:
bool wasShiftActive() {
return kaleidoscope::hid::wasModifierKeyActive(Key_LeftShift) ||
kaleidoscope::hid::wasModifierKeyActive(Key_RightShift);
}