Input echo when holding key, doesn't happen on gamepad

Godot Version

4.7.2

Question

I’ve been using Input.is_action_just_pressed() in my project to check if the player has just pressed a button, but I just realized that, if I hold down the key I assigned to the given action, this function returns true a bunch of times.

func _process(_delta : float) -> void:
	if Input.is_action_just_pressed("test"):
		print("test")

I tried using the _input() function instead, but results are the same.

func _input(event: InputEvent) -> void:
	if event.is_action_pressed("test"):
		print("test")

What’s weird is that I assigned a gamepad button to the given action in the Project Settings, and it works as expected in both cases. I don’t know what could be causing this. Can someone help me?

I think it has more to do with the os and the keyboard than godot itself. However, you should be able to avoid several triggers by checking if event.is_echo()

What’s your operating system? This sounds indeed like an accessibility feature. When set up “properly”, it allows you to hold down a single keyboard key and it would register as multiple button presses (just like regular repeated letters when holding down a regular keyboard key).

Also keep in mind your _input() function might not function the way you expect, as this will trigger on any event and would then just check whether the button is held, no matter whether it was pushed just this moment.

I forgot to mention I also tried using is_echo() like this:

func _input(event: InputEvent) -> void:
	if event.is_action_pressed("test") and not event.is_echo():
		print("test")

Didn’t work :frowning:

Also according to the docs for is_action_pressed():

Returns true if the given action matches this event and is being pressed (and is not an echo event for InputEventKey events, unless allow_echo is true).

So checking for echo shouldn’t be needed in the first place, right?

I’m thinking this could be a problem with your keyboard.

Do you have another keyboard you could test with? What about with your mouse?

Also, how frequently is the re-press happening? Is it multiple times in a second, or every so often?

I think I found the root of the problem. Looks like it’s coming from Godots, the version manager I use for my Godot projects. Tried running the project using the executable downloaded directly from the Godot website, for both Windows and CachyOS, and it worked as expected for both of them. Only when I ran the project using Godots did I get this issue.

So now what? Is there a way to fix this? Godots is too convenient for me to let go that easily :smiling_face_with_tear:

EDIT: I was using Godots on CachyOS, Plasma 6.8.1. Tried the project on Godots on Windows and it worked there too. So it’s a specific issue with Godots on my CachyOS. Damn…

I’d recommend letting the developer of Godots know about this issue! They probably have an issue tracker somewhere & you can open a ticket there ^^

I’ll do that, thanks!