Modifier & Shift Layer

What would be the easiest way of making a key activate a modifier (like pressing CTRL) and shifting to another layer at the same time?

I could program the key to shift to another layer where I make every key in that layer being pressed with the modifier (LCTRL(Key_…)), but that seems quite cumbersome to write and maintain. Is there another way to tackle this problem more elegantly?

:wink:

1 Like

Thanks. That only seems to cover when you want the prefix to be released before the key from the layer. As in CTRL+B X, for tmux, with CTRL+B being the prefix and released before the key X from the layer is being pressed. Very handy, but in my case I want the key from the layer to be prefixed with a key that is remained pressed down, as in CTRL+X, with CTRL being the prefix and being kept pressed down, then the key X from the layer being pressed and afterwards both keys are being released.

This might not work for you, but I stumbled across this thread in looking for a solution to my situation and figure it might help others:

I’m running MacOS and wanted to be able to pull up the application switcher with a key other than “tab” on the Model 01 and cycle through applications. I ran into the same problem- I could only switch layers with the key pressed down or trigger the command key press event; not both.

I ended up mapping MagicCombo to the keys I wanted to use instead of creating an entire layer. It works reasonably well, though there’s a moment in which it doesn’t capture repeated presses of the combo.

Relevant code:

USE_MAGIC_COMBOS({
/* Command+Tab on Command+Command press */
  .action=applicationSwitcher,
  .keys= { R1C7, R2C8 }
},
/* Add in Shift key to reverse it */
{
  .action=applicationSwitcherReverse,
  .keys= { R1C7, R0C7, R2C8 }
});

and

static void applicationSwitcher(uint8_t combo_index) {
      kaleidoscope::hid::pressKey(Key_Tab.keyCode, true);
}
static void applicationSwitcherReverse(uint8_t combo_index) {
      kaleidoscope::hid::pressKey(Key_Tab.keyCode, true);
}