Hi guys, is it possible to check if the player has pressed the key twice in a row? I'm trying to incorporate a 'dash' feature where it throws the player forward when they double-press a key.
Is there a built in proc or something for this? If not, what's the most efficient way to code one?
Thanks
ID:951143
![]() |
|
![]() Aug 28 2012, 8:54 am
Best response
|
|
You could use Forum_Account's keyboard library, make a variable to store the last key pressed and check it against the next key pressed. You could then possibly make a proc called double press or something like that to handle the behavior of that double press. You may also want to reset the variable to null after like a second.
|
Okay thanks that worked. Atm I've got:
var/d = 0 It works fine, the problem is if the user holds the same key down, it counts it as them pressing it again instead. Could someone write me a code to check if the key is being held down? Don't add it into my code please, I'd rather learn myself. Thanks |
Keep a list of keys held. On KeyDown, add the key to the list. Take it out on KeyUp.
|
Using Forum_account's Keyboard library, you have access to the key_down() and key_up() events. For double-tapping, you really only need to worry about key_down(), but it depends on what you mean by double-tapping. Here's what I've done:
mob The key-downs of a key must happen no more than 1/5th of a second apart. The double_tap(key) event is triggered when a successful double-tap has been performed. |