Python real-time keyboard input
Question: I am not looking for `input()` or `raw_input()`. I am looking for what sounds
like is available in the msvcrt module, specifically `msvcrt.kbhit()` and
`msvcrt.getch()`, but am unable to get it working.

I tried example 1, here:

<http://effbot.org/librarybook/msvcrt.htm>

and the chosen answer here:

[Python Windows `msvcrt.getch()` only detects every 3rd
keypress?](http://stackoverflow.com/questions/22365473/python-windows-msvcrt-
getch-only-detects-every-3rd-keypress)

both of which put me into infinite loops from which I am unable to escape by
pressing 'esc' and 'q' respectively.

    
    
    import msvcrt
    while True:
        pressedKey = msvcrt.getch()
        if pressedKey == 'x':    
           break
    

I would like to avoid downloading and installing new modules, like pyhook
suggested below, if possible:

[How do I get realtime keyboard input in
Python?](http://stackoverflow.com/questions/13694873/how-do-i-get-realtime-
keyboard-input-in-python)


Answer: I found the answer here: [Python kbhit()
problems](http://stackoverflow.com/questions/18672923/python-kbhit-problems)

Basically, you need to run the program from a console window instead of from
the IDE (Python in my case).

