I have a simple double tap system that works really well for every combination of WASD keys. Recently I expanded this to include triple taps using a single key (eg. WWW, AAA etc). Both of these work without any problems, but now I want to add multiple keys in the triple tap system (eg. WSA, WSD etc), exactly like what I have with the double tap but with a third key.
When testing the AWW combination, both the doubleTapAW bool and doubleTapW bool are triggered, but the AWW is not. There are 4 functions, each checks for all combinations starting with a particular key and triggers the relevant boolean based on what is detected. 4 timers are also used to check the time since the last relevant key press, and all the functions are then called from the update function. What am I doing wrong?
Ok, I figured out a simple solution for this. Basically I setup two string variables; one keeps track of the current double tap that was pressed, and the second adds that current double tap to the one stored previously. This allows me to keep track of the specific order that the keys were pressed.
Because of the way my double tap booleans are triggered, for any triple tap two double tap booleans will be triggered. For example, for the triple tap AWW, the AW bool will be triggered and the WW bool will be triggered as well. If both of these bools are true I can then check my string, and if the order is “AWWW” I know that the AW bool was triggered first. So I can set the AWW triple tap bool to true and create the needed functionality.
The only thing that needs to be added to this, is some sort of reset for the string variable adding the strings together, otherwise this will only work the very first time. This can be done by checking the string.length. Hope this helps others trying to do the same thing