function for key pressed once unity code example
Example: unity when key pressed
void Update()
{
if (Input.GetKeyDown("space"))
{
print("space key was pressed");
}
}
void Update()
{
if (Input.GetKeyDown("space"))
{
print("space key was pressed");
}
}