How do I make Python 3.5.2 wait for the space bar to be pressed on either Raspbian or OS X? I haven't been able to find any ways to do this. It would be fine if it didn't even pause the code, and I don't care about licensing.
Asked
Active
Viewed 2,916 times
-3
-
If you're prepared to settle for Enter, just use `input`. If not, do some research and read e.g. http://stackoverflow.com/q/983354/3001761. What does it even mean to wait without pausing the code? – jonrsharpe Nov 17 '16 at 23:22
-
http://stackoverflow.com/questions/32671306/how-can-i-read-keyboard-input-in-python – Dalvenjia Nov 17 '16 at 23:26
1 Answers
0
As jonsharpe said, you could use input
which would wait for enter, and if you are familiar with batch
, you'll feel right at home.
just use:
print('Waiting for enter')
pause = input('') #This will wait until you press enter before it continues with the program
print('You pressed enter!')
#Program terminates
I have found solutions for Windows, but I cannot find any concrete solutions for Raspbian or OS X. I will keep looking and if I find anything I will update the post.