How to detect if a Macro key is pressed

I’ve created a Cut, Copy and Paste macro which are activated when I press the Right-Function + X, C or V.
Now I’d like to enable the LED under these keys when I press the Right-Function keys.

I tried the following code:

if (Layer.isOn(2)) {
  if ((k.raw == Key_Z.raw) || (k.raw == Key_X.raw) || (k.raw == Key_C.raw) || (k.raw == Key_V.raw))  {
    ::LEDControl.setCrgbAt(r, c, highlight_color);

but that obviously won’t work as the pressed key is a macro key and not the X,C,V.
How can I check if the value in “k” is a macro key?

if ((k == M(MACRO_PASTE)) {

You can compare k to whatever you have on your keymap.

I’ve been (ab)using the Led-ActiveModColor plugin to control the LED’s.
In that code I can’t reference the macro key.

I guess it’s time to figure out how to move my code to the .ino file.

Thanks for the tip. I didn’t realize the Macro keys were instances of Key.
I added a few static properties to the plugin of type Key and set them in the main .ino.
That works!

1 Like