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 = ""
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?