Toggle a keystroke down/up with the same incoming signal?

I use a product called aerodrums that outputs midi signals to play games. Think of it like an electric drum kit basically. I need to be able to strike one drum to press a key down and hold it until i strike the same drum again.
All I can think of for now is to use a very long timer on the key up delay and have a seperate drum to be a global Key up command. But that will be a hassle. Any insight?

I had the idea of maybe creating some sort of feedback loop to hold down the same note that i’m using to input.
so like when I strike CH10 note 38 (the one i intend to use) it would output ch10 note 38 indefinitely, then have a second translator to turn that note held down into a keypress being held down. But I’m still not sure how i’d program the same note to also trigger a note off the next time i pressed it without the repeated “note on” canceling itself out by triggering the note off.

So you want it to on first hit, send keystroke down and on second hit send keystroke up and so on?

Exactly!

Hi Something like this will work.

I use a global variable ga to track the key state. I toggle it so that it moves from 0 to 1 and 1 to 0 on every key press.

The first translator only fires if ga=1 and presses the "a" key down. The first tranlator also performs the toggle

ga=ga^1

 

The second translator fires only if ga==0 and sends keystroke "a" up.

 

I hope this helps!

 


Attachments:
1599355953689_Toggle-Key-Example-2020-09-05.bmtp
1 Like

That worked perfectly! I just had to set gg as the variable on the second input i needed to also act that way. Thanks a lot! I had a feeling i was overthinking it a bit.

Glad to have been of help!