import _thread

def input_thread(list):
    input()
list.append(None)

def do_stuff():
    list = []
_thread.start_new_thread(input_thread, (list,))
while not list:
    stuff()
How to kill a while loop with a keystroke?