Re: stop program with entering a key

Use puts to print the screen and gets to get the user’s input.

I’m guessing you want to add something like

puts “pls press -1 to stop game”
answer = gets
if answer.to_i == -1 or answer == randomnumber
puts “Continue or stop? (y/n)”
answer = gets
if answer.chomps == “y”
puts “Thank you for playing, game over.”

Was that any help?