title: How to terminate the loop if user press any key in Ruby?
body: <p>As title says, I want to terminate loop if user press any key.
  Any key means if user simply press keyboard letter, 'A' and not press 'enter' after 'A', it should terminate the infinite loop. I did little research, and found out that using Thread is a key-point to solve this problem. However, since I just started learning Ruby a week ago, I just have no idea how to code tbh.</p>
  
  <pre><code>Thread.new do
    while user_input = STDIN.gets
      break if user_input.chomp == true # dont know what to write here
    end
  end
  
  loop do
    random = random_number(0,1)
    puts random
    total = random + total
    count += 1
    sleep 1
  end
  </code></pre>
  
  <p>This is code I have now, and of course its not working..
  I need help...(I am worrying that Thread has to be done with 'Enter'. Like it terminates loop when user press 'any key' and 'Enter'.. And that is not what I want)</p>