I press key onces, but godot react twice

Godot Version

Question

i have this func. if i press “menu_key” it print out “Test Key” two times.

How to prevent this from happening
On the Node itself the Process Mode is “Always”

And my game didn’t pause ether, because the function runs twice (The HUD Scene is a autoload)

EDIT: the Script is only attached to one Node (the HUD) and this also happens if the autoload is disabled

func _process(delta):
	change_score()
	display_hud()
	display_key()
	if Input.is_action_just_pressed("Menu_key"):
		print("Test key")
		if Engine.time_scale == 0:
			Engine.time_scale = 1
		else:
			Engine.time_scale = 0

You may have repeated your input processing in another part of your program.

So i cannot have two different nodes listen for inputs ?

Sure you can. You just have to be aware of where you’re doing it and why, and keep it in mind if you’re getting unexpected results. It could be the reason you’re getting duplicate messages.

1 Like