Out of curiosity, what purpose does this serve? Most of the time, modifiers pressed and released on their own have no effect; do you want it to be a OneShot control
?
For the rest of it, we should start with the fact that you want the key’s behaviour to distinguish between a tap and a hold, for which you should use Qukeys. Next, you want its output when tapped to depend on the number of taps, for which you need TapDance. Fortunately, these two plugins can be combined and used on the same key, if you’re careful.
In your keymap, you can define a key as TD(0)
; that sets up a TapDance key with index 0
. Then you’ll need to add the following code to your sketch:
void tapDanceAction(uint8_t tap_dance_index, KeyAddr key_addr, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action) {
switch (tap_dance_index) {
case 0:
return tapDanceActionKeys(tap_count, tap_dance_action, Key_LeftControl, LockLayer(1));
}
}
This will set up that key such that one tap will result in control
, and two taps will activate Layer 1. You could change that to MoveToLayer(1)
, if you prefer to also turn off other active layers.
In addition, you’ll need to define a Qukey
object. Inside your sketch’s setup()
function, add this (replacing the key coordinates with the layer, row, and column numbers corresponding to the TD(0)
key in your keymap):
void setup() {
QUKEYS(
kaleidoscope::plugin::Qukey(0, KeyAddr(2, 3), Key_LeftControl)
);
// The rest of setup() goes here...
}
This defines a single Qukey
on layer 0
, row 2
, column 3
, which will become Key_LeftControl
if used in combination with another key or held long enough on its own.
Note: The order of the plugins is important. You should have the following elsewhere in your sketch:
KALEIDOSCOPE_INIT_PLUGINS(
Qukeys,
TapDance,
// other plugins go after those two...
);
It’s important to discriminate between a “tap” and a “hold” first, then to count taps to determine what to do. And for now, it’s especially important to put them in this order, because TapDance has a bug where you’ll get a tremendous number of on-off cycles if you hold a TapDance key past its timeout value. Having Qukeys first will prevent TapDance from getting that trigger.