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?
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: