I have an infinite while loop that I want to break out of when the user presses a key. Usually I use raw_input
to get the user's response; however, I need raw_input
to not wait for the response. I want something like this:
print 'Press enter to continue.'
while True:
# Do stuff
#
# User pressed enter, break out of loop
This should be a simple, but I can't seem to figure it out. I'm leaning towards a solution using threading, but I would rather not have to do that. How can I accomplish this?
msvcrt
module. – Biddle