Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_wait4singlekeypress.py
- import msvcrt, time
- print "press 'escape' to exit..."
- t = time.time()+1
- while 1:
- char = msvcrt.getch()
- if char == chr(27):
- break
- elif char == chr(13):
- print 'return key was pressed'
- elif char == ' ':
- print 'spacebar was pressed'
- else:
- print char
- if time.time() > t:
- print 'this line prints after every 1 sec of the last pressed key'
- t = time.time()+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement