Hello,
 
I'm just starting programming in Python. ATM I do write some smaller practices. 
In them I want to read single keys, if pressed. If none pressed I do not want 
to wait.
 
In the library reference I found "kbhit()" and "getch()" from msvcrt. I import 
msvcrt (running on Windows) but I cant get it to run. Is ther somewhere a 
sample I could peek on?
And is there somthing not windows specific?
 
My trial code is:
 

import msvcrt
 
def kb():
    while( 1 ):
        if msvcrt.kbhit():
            print "key seen"
            help = msvcrt.getch()
            #if( help < 255 ):
            print help, ord( help )
            if( ord( help ) == 27 ):
                print "cancel"
                break

 
It appears to never see a key. 

Mit freundlichen Grüßen
Matthias Sommer
Entwicklung - Firmware/Elektronik
______________________________________________

Wincor Nixdorf Technology GmbH
Am Vogelherd 67
D - 98693 Ilmenau, Germany

Tel.:        +49 (0) 36 77 862-194
Fax:        +49 (0) 36 77 862-199
E-Mail:    [EMAIL PROTECTED]
               www.wincor-nixdorf.com <http://www.wincor-nixdorf.com/> 


 

-- 
Wincor Nixdorf Technology GmbH
Sitz der Gesellschaft: Paderborn
Registergericht Paderborn HRB 3523
Geschäftsführer: Eckard Heidloff, Jürgen Wilde, Wolfgang Keller
Steuernummer: 339/5884/0020 - Ust-ID Nr.: DE243233085

Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der richtige 
Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie 
bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte 
Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential information. If you are not the intended 
recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorised copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden. 

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to