Macros and modifiers, again

Hello, I’m trying to create a macro on my Model01 that does different things based on whether or not alt is pressed.
Basically, I’d like (e.g.)

  • pushing f should emit ‘f’
  • pushing alt-f should emit control-rightarrow

I’m ironically running into the opposite problem that was described in this earlier thread – I am unable in my macro to reset the state of the alt key, so I get control-alt-right arrow instead of just control-rightarrow.

Here was my first naive attempt:

static const macro_t *fMacro(uint8_t keyState) {
    if (keyToggledOn(keyState)) {
        if (kaleidoscope::Runtime.hid().keyboard().wasModifierKeyActive(Key_LeftAlt)) {
            return MACRO(D(LeftControl), T(RightArrow), U(LeftControl));
        } else {
            return MACRO(T(F));
        }
    }
    return MACRO_NONE;
}

In the rest of the code fragments I’ll just focus on the code in the if (kaleidoscope... block since that’s the only thing I’m fiddling with.

I tried releasing the key:

return MACRO(U(LeftAlt), D(LeftControl), T(RightArrrow), U(LeftControl), D(LeftAlt));

I tried tapping the key:

return MACRO(T(LeftAlt), D(LeftControl), T(RightArrrow), U(LeftControl), D(LeftAlt));

I tried other keyboard APIs:

kaleidoscope::Runtime.hid().keyboard.releaseRawKey(Key_LeftAlt);
return MACRO(D(LeftControl), T(RightArrrow), U(LeftControl));

None of these yield a key-release event for the alt key.

In case it matters, the alt key in question is actually one of the thumb keys set to a QuKey using ALT_T(Home)

Any hints or pointers as to what I’m doing wrong?

Thanks!