title: Python create a thread and start it on key pressed
body: <p>I've made a python script that factorizes a number into its prime factors. However when dealing with big numbers i may like to have an idea to the progress of the computation. (I simplified the script)</p>
  
  <pre><code>import time, sys, threading
  
  num = int(input("Input the number to factor: "))
  factors = []
  
  def check_progress():
      but = input("Press p: ")
      if but == "p":
          tot = int(num**(1/2))
          print("Step ", k, " of ", tot, " -- ", round(k*100/tot,5), "%", end="\r", sep="")
  
  
  t = threading.Thread(target=check_progress) ?
  t.daemon = True ?
  t.start() ?
  
  k = 1
  while(k != int(num**(1/2))):
      k = (k+1)
      if num%k == 0:
          factors.append(int(k))
          num = num//k
          k = 1
  print(factors)
  </code></pre>
  
  <p>I'm wondering if there is a way to show the progress on demand, for example, during the loop, i press a key and it prints the progress?</p>
  
  <p>How can i implement a thread of something like that in my script?</p>
  
  <p>Thanks and sorry for my english</p>
  
  <p>Edit:</p>
  
  <pre><code>def check_progress():
      while True:
          but = input("## Press return to show progress ##")
          tot = int(num**(1/2))
          print("Step ", k, " of ", tot, " -- ", round(k*100/tot,5), "%", sep="")
  </code></pre>