How to check if the Input is null

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

I need to make a variable that is true if ANY key is pressed or just pressed and if you let no key pressed the variable is false

exemple:

if (input == any key): - Just an idea
      any_key = true
else: (if input == null)
      any_key = false

thanks, I hope you understand

:bust_in_silhouette: Reply From: Andy

For Godot 3.2:

In menu Project -> Project Settings -> Input Map add custom Action. For example, jump.
Add key to this Action.

Now you need to check for this action somewhere.
Let’s say you have Player scene, root Node is a KinematicBody2D and GDScript attached to it.

In script add function:

func _physics_process(delta):
    if Input.is_action_pressed("jump"):
        # add desired outcome here
:bust_in_silhouette: Reply From: jgodfrey

These both seem to answer your question:

https://forum.godotengine.org/28616/how-can-check-to-see-if-any-key-on-the-keyboard-has-been-pressed

https://www.reddit.com/r/godot/comments/d1ow70/any_key_input/