python Newbie Question: key-press capturing.

marco marco at mfa.mohr-i.nl
Mon Oct 21 10:07:51 EDT 2002


Hi,
I just started with programming in python. I used to work with
Qbasic.I already made some little functions in Python but I can't fix
this problem with keyboard capturing.

I want to make a simple sequenser function that prints "pulse" and
stops when a key (forexample "q") is pressed.

I tried to use the functions "raw_input" and "sys.stdin.read()" but
they somehow it blocks out the rest of the code, the print "pulse"
line doesn't work anymore.

#------------------------------------------------------
key=""
x=0

while 1:
 key = raw_input()
 x =x+1
 if x > 100000:
     print "pulse"
     x=0
 if key == "q":
     break
print "q pressed"
#------------------------------------------------------

Thanks 4 your attention.


M. Theunissen
marco at mfa.mohr-i.nl



More information about the Python-list mailing list