Double tap

=How do you do a double tap on a key= FirstW is a boolean variable I defined. The kode: (1)WHEN [W][pressed] DO (2)  WHEN [FirstW]  DO [jump] (3)  WHEN  DO [toggle][FirstW] (4)WHEN [FirstW] DO (5)   WHEN [countdown][10][in frames]  do [FirstW][equals][false] The code may be self explanatory for some of us, but for those it isnt:

Line 1 detect key press, Lines 2 - 4 will only execute if key is pressed

Line 2 asks have you pressed the key a first time recently enough for double tap, if yes, it resets double tap detection and executes line 3

Line 3 is where you put kode you want to happen on double tap. A single line or insert more

Line 4 if you didn't hit key recently (tested on line 2) then this line is fallback and sets the variable to indicate the first keypress has happened

Line 5 - 6 asks if first key press has previously been registered, if it has it then asks has a period of time elapsed, if is has elapsed then reset the variable. i.e. Second tap hasn't happened in time.

Line 6, Countdown in my example is set to 10 frames, which means there is 1/3 of sec to hit the a key 2nd time. PS runs at 30fps (frames per second).

This can of course be used for controller buttons, mouse clicks etc. Each key or button will require its own boolean variable and 6 lines of kode.