_unhandled_key_input(event) returning 2 values

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nic

Im making a typing game to familiarize myself with this side of godot, and im having some issues with _unhandled_key_input(event). I know its SUPPOSED to return 2 values, but I need it to return a value only when im pressing the key, and not when its being released. This is because after the first time its pressed, my code tells it to move to the next letter in the word, which is then though of as incorrect.

Example: The word is “Hello!” so when I press H, it is correct when pressed, but incorrect when released because its checking for the value “e” but gets “h”.

Heres the code im using for this currently, if you need to see it. Just fyi, the whole “WordProgress” thing is just to show how far along you are into the word, it has no significance for this issue.

func _unhandled_key_input(event):
	var KeyPressed = event.as_text()
	check_event(KeyPressed)



	
func check_event(event):
	if event == KeyArray[Currentletter]:
		if event != "Space":
			$WordProgress.text += str(event)
		else:
			$WordProgress.text += "_"
		Currentletter += 1
		if Currentletter == LengthOfWord:
			word_completed()
	else:
		punish()
:bust_in_silhouette: Reply From: LoneDespair

Maybe try adding a check if the key is pressed or released
if event.pressed: