No one has mentioned this (even though the OP fixed his problem with a "flag" variable):
It depends on how you intercept the signals. If you are handling it through _input()
or _gui_input()
, for example, you will get both KEY DOWN and KEY UP events for a single key press.
Additionally, depending on your system settings, you might even be getting KEY REPEAT events — which to you will look like multiple KEY DOWNs.
Unfortunately from the GDScript end of things you must handle this through careful consideration of which event you will observe and using "flag" variables or watching the time when and event is fired.
Hope this helps.