Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tuulis |
Hello, I’m still a beginner with Godot and GDScript. This is not a very important question and it might be a dumb one but I’m just asking it to better understand what’s happening.
Ok, so when I execute the following code it will obviously print “KEY_UP” every time I press the up arrow key:
func _unhandled_key_input(event):
if event is InputEventKey:
if event.pressed and event.scancode == KEY_UP:
print("KEY_UP")
Now when I omit the “event.pressed” it will do basically the same but now it will print the “KEY_UP” twice every time the up arrow key is pressed:
func _unhandled_key_input(event):
if event is InputEventKey:
if event.scancode == KEY_UP:
print("KEY_UP")
Why is it now printing it twice?