title: Python event loop -- multithreading -- How to run two bits of code simultaneously?
body: <p>So I'm trying to utilize <code>msvcrt.getch()</code> to make an option to quit(without using KeyBoardInterrupt) anywhere in the program. </p>
  
  <p>My code currently looks like this:</p>
  
  <p>import msvcrt
  import sys</p>
  
  <p>print("Press q at any time to quit")</p>
  
  <pre><code>while True:
      pressedKey = msvcrt.getch()
      if pressedKey == 'q':    
         sys.exit()
      else:
         # do some setup
         if myvar == "string":
             try:
                 # do stuff
             except:
                 # do stuff 
         else:
             #do stuff
  </code></pre>
  
  <p>How do I run the while loop to detect the keypress of <kbd>q</kbd> at the same time as I'm running the other (the <code># do stuff</code> blocks)?</p>
  
  <p>That way, if the user goes ahead with the program, they it'll only run it once. But if they hit <kbd>q</kbd>, then the program will quit.</p>