0 votes

I have a TextEdit node, and inside of it I've declared the _gui_input function. Upon typing anything in the text box, the keystroke is put through the function twice. For example:

func _gui_input(event):
    if event is InputEventKey:

will print out "s," and then "s" again, even if I've only hit the S key once. is_echo returns false on the original and duplicate event.

Is this intended behavior? I would imagine the input is only supposed to be registered once, which is what I want.

Godot version 3.2.3
in Engine by (15 points)

1 Answer

+2 votes
Best answer

This is intended behavior because you're generating two key events: press and release. If you only want the keypress event, you need to add that to your condition:

func _gui_input(event):
    if event is InputEventKey and event.pressed:

More information:

by (20,901 points)
selected by

Thank you very much. I don't know how I missed that.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.