How to use numbers as a Input?

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

I want to print anything, if I press the 1 on the keyboard. I already know how to do it with a letter:

if Input.is_key_pressed(KEY_A):
       print("Hello")

But now I want to know how to do this with a number instead of A.

:bust_in_silhouette: Reply From: Sween123

Change the KEY_A to KEY_ + number. For example: if Input.is_key_pressed(KEY_1)

For more inputs control, for example, print hello when number 1 OR 2 is pressed. Go to Project settings - Input Map, and you can create your own actions and what keys will trigger them. In code to check these actions: Input.action_pressed(YOURACTION)