How can i Identified the Key is Pressed Multiple Times

Hi All

I am new bie to unity. In my project i have to press space bar multiple time.

for eg: if first time space bar pressed it should display “1st” and second time pressed “2nd timepressed” and third time

3 rd Pressed.all should complete within 1 minutes. after 1 minutes the timer should reset.

how can i do it.

I have code for first time . I don’t know how to do it for second and third time display?

if (Input.GetKeyDown (KeyCode.Space))
print (“I st time Pressed”);

Try creating a variable of type integer that increments every time you press space. To create the variable, try this:

int myNumber = 0;

Then in your Update Function type this:

If (Input.GetKeyDown (KeyCode.Space)) {
    myNumber += 1;
    if (myNumber > 1)
        print("Pressed " + myNumber + " times.")
        print("Pressed once.")

Hope this helps! :slight_smile: