[SOLVED] How do I get unicode only once on keystrokes?

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

If is_pressed is true, you can get unicode. But if you keep pressing it, you’ll get the unicode continuously.
I wanted to get unicode only once on input, so I thought about getting unicode when is_pressed is not. But it gets the unicode with 0. I don’t know the cause. Is there a solution or other means?

 func _unhandled_key_input(event):
	if event.is_pressed():
		print(event.unicode)

The unicode will be obtained by value.

  func _unhandled_key_input(event):
	if not event.is_pressed():
		print(event.unicode)

The unicode will be obtained by 0.

:bust_in_silhouette: Reply From: njamster
func _unhandled_key_input(event):
if event.is_pressed() and not event.echo:
	print(event.unicode)

Hello, Thank you for the answer.
Your answer solved the question.

Thanks.

koba | 2020-07-23 21:00