# Macros and modifiers, again

**URL:** <https://community.keyboard.io/t/macros-and-modifiers-again/6672>\
**Category:** Programming\
**Tags:** question\
**Created:** [April 5, 2024, 5:57am UTC](https://community.keyboard.io/t/macros-and-modifiers-again/6672 "2024-04-05T05:57:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenobi](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@kenobi](https://community.keyboard.io/u/kenobi)\
**Post date:** [April 5, 2024, 5:57am UTC](https://community.keyboard.io/t/macros-and-modifiers-again/6672/1 "2024-04-05T05:57:04Z")

</div>

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](https://community.keyboard.io/t/combining-macros-with-modifiers/980) 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:

```auto
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:

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

```

I tried tapping the key:

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

```

I tried other keyboard APIs:

```auto
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!
