[Tutor] push a keyboard button to run a function

Chris C mysecretrobotfactory at gmail.com
Fri Apr 10 19:31:17 EDT 2020


It's CLI under windows, with no GUI

Can i just use this ?  msvcrt.getch()

thanks!

On Fri, Apr 10, 2020 at 4:17 PM Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 10/04/2020 23:11, Chris C wrote:
>
> > I am trying to invoke a function in my python code by using a keyboard
> > keystroke.
>
> You need to tell us more.
> Is this a CLI program or a GUI? If a GUI which toolkit?
> Tkinter? wxPython? other...
> If a CLI which OS? If it is Unix like then the curses module
> is your friend.
> If its Windows the msvcrt module will help.
>
> > Alternatively, I need to change a variable's value from true to false and
> > false to true everytime when I push this button,
> >
>
> variable = not variable
>
> will toggle a boolean between true/false.
>
> But we need more context information to answer fully.
> Ideally some code (even if it doesn't work) to see what
> you are attempting.
>
> --
> 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
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list