Skip to content

Add Input `is_anything_pressed` method

Andrii Doroshenko requested to merge github/fork/Xrayez/press-any-key into master

Your typical "Press any key" use case using the Input singleton, can also be used to conveniently detect and switch various idle states, such as character switching to bored state if you wish so. 🙂

func _physics_process(_delta):
	if Input.is_anything_pressed():
		$message.text = "Thanks!"

There's another way for doing so using _input:

func _input(event):
	if event.is_pressed():
		$message.text = "Thanks!"

But it might not be possible to achieve in the future according to:

https://github.com/godotengine/godot/blob/02cd1442227127604549159d66b9bfc68a193dd3/core/os/input_event.h#L191-L194

In any case, I'm here to tell that it might be a good idea to leave InputEvent.is_pressed() as is.

Test project

press-any-key.zip

Merge request reports