# Macro with multiple modifiers

**URL:** <https://community.keyboard.io/t/macro-with-multiple-modifiers/6384>\
**Category:** Programming\
**Tags:** plugin\
**Created:** [May 21, 2023, 4:13pm UTC](https://community.keyboard.io/t/macro-with-multiple-modifiers/6384 "2023-05-21T16:13:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowkeep](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/snowkeep/32/4236_2.png) [@snowkeep](https://community.keyboard.io/u/snowkeep)\
**Post date:** [May 21, 2023, 4:13pm UTC](https://community.keyboard.io/t/macro-with-multiple-modifiers/6384/1 "2023-05-21T16:13:33Z")

</div>

I’m attempting to port a macro to Kaleidoscope that enters a different set of enclosures depending on the modifier pressed. This is what I have:

```auto
#define K_LT LSHIFT(Key_Comma)
#define K_GT LSHIFT(Key_Period)
#define K_LParen LSHIFT(Key_9)
#define K_RParen LSHIFT(Key_0)

namespace kaleidoscope {
  namespace plugin {

    class ModBlocker : public Plugin {
      public:
        EventHandlerResult onAddToReport(Key key) {
          if (active_ && key.isKeyboardModifier())
            return EventHandlerResult::ABORT;
          return EventHandlerResult::OK;
        }

        void enable() {
          active_ = true;
        }
        void disable() {
          active_ = false;
        }

      private:
        bool active_{false};
    };
  }
} 

kaleidoscope::plugin::ModBlocker ModBlocker;

const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) {
  switch (macro_id) {

  case MACRO_VERSION_INFO:
    versionInfoMacro(event.state);
    break;

  case MACRO_BRACES:
    if (keyToggledOn(event.state)) {
      if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftAlt)) {
        Macros.tap(K_LParen);
        Macros.tap(K_RParen);
      }
      else if (Kaleidoscope.hid().keyboard().wasModifierKeyActive(Key_LeftControl)) {
        Macros.tap(K_LT);
        Macros.tap(K_GT);
      }
      else {
        // this handles shift too
        Macros.tap(Key_LeftBracket);
        Macros.tap(Key_RightBracket);
      }
      ModBlocker.enable();
      Macros.tap(Key_LeftArrow);
      ModBlocker.disable();
      return MACRO_NONE;
    }
    break;
  }
  return MACRO_NONE;
}

```

The ModBlocker plugin is based on the ShiftBlocker example, but the enable does not work so the LeftArrow tap is getting mangled. Any suggestions?

---

<div class="post-metadata">

**Author:** ![snowkeep](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/snowkeep/32/4236_2.png) [@snowkeep](https://community.keyboard.io/u/snowkeep)\
**Post date:** [May 23, 2023, 1:24am UTC](https://community.keyboard.io/t/macro-with-multiple-modifiers/6384/2 "2023-05-23T01:24:13Z")

</div>

Can anyone confirm if the regular ShiftBlocker works with a current checkout? I can’t get it to work, either.
