How to display a message, wait for keypress and again and again?

I tried doing this with a coroutine,
and it waits for the keypress before showing the message,
but once I press the key all the messages are showed at the time.

I want to make something like this:

Debug.Log("Message 1");
-Wait for key press-
Debug.Log("Message 2");
-Wait for key press-
Debug.Log("Message 3");
...

So that first message is displayed at the beggining, then when I press a key message 2 is displayed but not message 3, and once I press a key again, then message 3 is displayed (and again for a lot of messages).

So as you can guess, it’s to make a dialogue.
Any help? :slight_smile:

you can count number of times that the has been pressed

int number=0;
if (Input.GetKeyDown("space")){
            number++;
          if(number==1)
           Debug.Log("Message 1");
          else if(number==2)
             Debug.Log("Message 1");    
          else if(number==3)
               Debug.Log("Message 1");
}