0 votes

So I made a dictionary with the key:value pair of (KEY_(SOME CHARACTER):"some character"). Then I wrote the following code to display a message that I type out on the keyboard.

var message = ""
func _process(delta):
func _input(event):
    if event.type == InputEvent.KEY:
        for i in keys: # keys is the dictionary I mentioned
             if event.scancode == i:
                  message += keys[i]

The problem here is that if I hold a key down, the program will still keep recieving input. And the program runs way faster then I type, resulting in messages like this (hheeeellllo wwwoorrld) from just trying to type regularly. Any built in method that can fix this?

Update 1: I tried

if event.type == InputEvent.KEY and !event.is_echo()

but I still got the same result. Using

if event.type == InputEvent.KEY and !event.is_pressed()

works way better, but with the above code I notice a lag between when I type a character, and when it is displayed on the screen. Anyone know why that lag is there?

in Engine by (29 points)
edited by

1 Answer

0 votes

You are receiving an event echo, do:

event.type == InputEvent.KEY && !event.is_echo() #and not is_echo
by (7,890 points)

I am curious, there is not much of a description in the API, what is an echo?

I've just been using event.is_pressed() to know if the key is held or not.

I guess is a hardware/driver "feature" on keyboards.

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.