Combo modifiers

I am very new to the topic of custumizing my firmware. I was just planning on how to structure my layers and how to switch to them and would like to be able to press two keys on my home row simultaneously for shifting to a specific layer (e.g. D and F pressed and hold together should temporarily switch to layer 5 until the keys are released again).

It seems that the Qukeys plugin is able to give keys a dual use function (either the actual character or being used as a modifier). However it seems to be only capable of handling a single key, not a combination of keys.

The MagicCombo plugins seems to handle arbitrary key combos, but just emits a series of keystrokes. It does not seem to be usable for a layer shift.

Can someone advice me, how to achieve the above mentioned?

I think the simplest way to do this at the moment is to use a combination of Qukey, and a custom macro. You’d set up your D and F keys to be a macro key on hold, lets call those macros MACRO_LAYER_D and MACRO_LAYER_F, and set up your macroActions() to delegate handling both to the same function, which would look like this:

static uint8_t layer_5_key_counter = 0;

void layer5Macro(const uint8_t macro_index, KeyEvent &event) {
  if (keyToggledOn(event.state)) layer_5_key_counter++;
  if (keyToggledOff(event.state)) layer_5_key_counter--;

  if (layer_5_key_counter == 2) {
    Layer.activate(5);
  } else {
    Layer.deactivate(5);
  }
}

That sounds interesting. Thanks!

I just tried it and of course it does not work as expected (I have probably done something stupidly wrong).

Is there a way to debug my code to see what actually happens? For example I’d like to see when a certain macro is triggered, the counter has changed, etc.

Can you share your whole sketch? That would help with debugging.

I usually use the Ancient Technique of Printf Debugging. As in, Focus.send("triggering macro:", macroIndex) in strategic places, and attach a serial console to the keyboard’s serial port.

Many thanks! That actually does help!

I am still playing around with it. It is a good mess. It seems that I have found the mistake I made.

But thanks for your proposal. I will certainly come back to it, when I get to the next problem. :slight_smile:

@hupfdule any progress on this?