how to detect if key is pressed unity script code example
Example 1: unity check if key pressed
if (Input.GetKeyDown(KeyCode.KEY))
Example 2: unity when key pressed
void Update()
{
if (Input.GetKeyDown("space"))
{
print("space key was pressed");
}
}