Checking if shift is held down in a macro

Hi.

I’m trying to make a macro that should do
alt-u a
This is because that will create the character ä on a mac with US layout

This is easy to do with the following code

  case MACRO_SWE_AE:
    if (keyToggledOff(keyState)) {
      return MACRO(I(25), D(LeftAlt), T(U), U(LeftAlt), T(A));
    }
    break; 

The problem now is that if I hold down shift and hit this button, it will obviously do alt-shift-u which is wrong.

So I need to check if shift is held, release it in code, do the macro, then hold it again.
I did do the same thing in QMK but fail to find how to do it in the documentation for Kaleidoscope.

Thankful for any help

I think this should still work to check if shift is currently active.

    if (kaleidoscope::Runtime.hid().keyboard().isModifierKeyActive(Key_LeftShift) ||
        kaleidoscope::Runtime.hid().keyboard().isModifierKeyActive(Key_RightShift))

Releasing it can be done with the macro then like MACRO(U(LeftShift), U(RightShift) ....

1 Like

Thank you. That works perfectly

I use the macro with the compose key in osx to do danish characters:

This means that you have to use a custom keyboard layout on your mac, right?
That’s what I do currently but I would like to use the default US layout. Right now I have a custom colemak layout that has some extra ways to do the swedish chars and that works fine but it’s just not as fun.

Also, as a bonus, by using the default US layout and still getting colemak, with a way to do swedish chars, means that I can connect the keyboard to an ipad and still getting everything working

This is embarrassing. It looks like I forgot how my own keyboard works :confused:

On second thought (and investigation) it turns out that I don’t use the compose key anymore. I just rely on the alt keys in mac os. But on windows I do/did rely on the compose key.

I am also a colemak user, but I set the keyboard layout from the OS.

I have really spent a long time trying to key my layout right and especially mapping of danish characters have been really painful!