TapDance and OneShot combination?

Hello. Normally if an OneShot key is hit twice, it will make it sticky. However, I would like to use TapDance so that if a key is pressed once it is a OneShot RAlt, but if it is pressed twice it is a OneShot RCtrl. Is this possible?

I don’t want to disable the OneShot sticky behaviour in general as I want to use it for other modifiers.

@algernon and others? :bouquet::bouquet::grapes::apple:

I think this should be possible. You might want to use OneShot.inject from the TapDance action handler, but other than that, it should work.

1 Like

Um sorry but I did look into the TapDance documentation but that seems to recommend using tapDanceActionKeys which takes a sequence of required keycodes as arguments so where can I use OneShot.inject()?

tapDanceActionKeys is just a helper, you don’t need to use it. For a few examples of how you can accomplish stuff without it, have a look at my TapDance setup.

Additionally, if you can open an issue against TapDance, to improve the docs to show usage without tapDanceActionKeys, that would be great, and I wouldn’t forget to write it, eventually. Thanks =)

What would I have to pass to OneShot.inject() as keyState when calling it from my tapdance action?

What I want to archive is activate a layer permanently or just for “one shot”, but the OneShot part doesn’t work.
Here is what I’ve got so far:

void activateXcodeLayer(uint8_t tapCount, byte row, byte col, kaleidoscope::TapDance::ActionType 
tapDanceAction) {
  if (tapDanceAction != kaleidoscope::TapDance::Release) {
    return;
  }
  if (::Layer.isOn(XCODE)) {
    return;
  }

  if (tapCount == 1) {
    ::OneShot.inject(OSL(XCODE), INJECTED);
  } else {
    ::Layer.on(XCODE);
  }
}

@jamadagni Did you get yours to work?
@algernon Any suggestions?

Thank You!

For keyState, you probably want IS_PRESSED.

Two separate calls with IS_PRESSED and WAS_PRESSED kind of worked, but lead to other problems.

I saw only now, that OneShot has a property called double_tap_sticky_layers.
What exactly is this supposed to do?

At first I thought it’s exactly what I was looking for, but it doesn’t behave at all as I would expect. What I would have expected is this: One tap switches layers for one key stroke, a double tap switches layers until I tap the key again. Did I understand this correctly? @algernon

I had some other key in the second layer that lead to the weird behavior. Replacing that with ___ fixed all the issues I had.