graphtheory123
graphtheory123

Reputation: 307

How to continue to next loop iteration only if I press a certain key in Julia

I am using Julia in Atom. I have a for loop which prints out information in each iteration. I want Julia to pause the program at the end of each iteration so that it only continues to the next iteration if a certain key is pressed (for instance, say the 'enter' key) in the REPL. How should I do this?

Upvotes: 1

Views: 767

Answers (1)

EricLavault
EricLavault

Reputation: 16035

The following should work (in REPL as well) :

for i in 1:3
    # ...
    println("something")
    readline() # wait for enter key press
end

Using readline() captures keystrokes (which you can assign to a variable to actually read them) until you press enter.

Upvotes: 2

Related Questions