unity script if key is pressed 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");
}
}