[Tutor] Fwd: Re: call key on_press event multiple times when key is held down

Alan Gauld alan.gauld at yahoo.co.uk
Tue Jul 4 07:33:14 EDT 2017

On 04/07/17 12:00, Alan Gauld via Tutor wrote:

>> the library you are using, I normally just use the standard
>> library for such things, or build a simple GUI…
> Standard library being?.. 

The Python standard library that ships with Python and
is documented on python.org. As in:

>> There are several but it depends on your OS.
>> In the standard library
>> Unix variants can use curses.
>> Windows users have msvcrt.

> Interesting solution, but still find a bit "dirty hackish”
> to involve a timer in this..  I guess it just would be neat if 
> it just worked as i thought it to be.  But i guess i have to look into curses.

A timer based loop is actually the standard pattern for
implementing a loop in an event driven environment (the
main alternative is to launch a background thread).
It's how most GUIs handle such scenarios.

The problem in a CLI solution is that you have to build your
own timer event system (usually based on time.sleep() or
similar). Hence the suggestion to use a GUI.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list