how can i calculate the time of pressed key?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mdswamp

Hi people,…
i have animated sprite with multiple animation, when i press specific keyboard key one of them is playing, but the problem is that if i press the key quickly (quick press and release), just beginning frames of animation plays. how can i calculate the intervals of key pressing and disable the specific animation if pressing intervals is smaller than animation time?
thank you

(p.s: i use godot v2.1.5)

:bust_in_silhouette: Reply From: hinasis

I don’t know how short are your animations but you can try something like:

Have a timer with the minimal interval time you want to wait to play the animation, say 0.1secs , when the key is down run the timer if it’s not, and then with the timer’s time out signal connected to the function that runs the animation.