How can you limit Input from infinite(by holding a key down) to check was it pressed and released

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Serenade
:warning: Old Version Published before Godot 3 was released.

Hi!
I cant figure out how to make code for input.
When you bound a key to a action, action will happen every frame as long as you ceep button pressed down.
How can i write code to make it check - was it pressed- only once, untill its released and do that again when needed (like with attack functions)
But without Timer nodes…

p.s. Im guessing you are operating with “was_pressed” or such functions…?

:bust_in_silhouette: Reply From: eons

Same question here with answers for Input: https://forum.godotengine.org/9148/on-key-press-do-xy-just-once

For InputEvent: https://forum.godotengine.org/5707/how-to-avoid-key-typing-repetition

:bust_in_silhouette: Reply From: Tybobobo

I’ve made a video response to this question. :slight_smile:

How to handle input and prevent looping;
QA Answer