At 01:57 AM 8/28/2006, Alan Gauld wrote: > > while answer == "": > > c = 0 > > timeStart = time.time() > > while True: > > c += 1 > > if msvcrt.kbhit(): > > if msvcrt.getch() == ' ': > > break > > if msvcrt.kbhit(): > > if msvcrt.getch() == 'h': > > print "Hello" > > if msvcrt.kbhit(): > > if msvcrt.getch() == 'q': > > answer = "quit" > >You only need one kbhit to tell you if any key has been hit at all. >Then you can use getch to fetch that key and store it in a variable. >Then the code above turns into: > >while True: > if kbhit(): key = getch() > if key == ' ': break > elif key == 'h': print 'hello' > elif key == 'q': answer = 'quit' > >Does that make sense?
Yes! Now my script runs perfectly. And I can add other keys for doing other things on the fly, as it were. That's what I was after. Thanks, Alan. Dick _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor