[Tutor] push a keyboard button to run a function
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Apr 11 06:49:26 EDT 2020
On 11/04/2020 00:32, Chris C wrote:
> how about
>
>
> while msvcrt.getch() != 'F2':
> time.sleep(1)
Sort of, except you need to read the docs for getch() closely.
Notice that
1) it returns bytes not a string
2) if the key is special - eg a Function Key - you need a
second getch() call to get the real key...
If you read the "Event Driven programming topic in my
tutor(see .sig) you will see an example of using msvcrt.getch()
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list