Wait for a keypress before continuing?

Terry Reedy tjreedy at udel.edu
Wed Aug 17 19:02:35 CEST 2011

On 8/17/2011 12:33 PM, Seebs wrote:
> On 2011-08-17, peter<peter.mosley at talk21.com>  wrote:
>> Is there an equivalent to msvcrt for Linux users?  I haven't found
>> one, and have resorted to some very clumsy code which turns off
>> keyboard excho then reads stdin. Seems such an obvious thing to want
>> to do I am surprised there is not a standard library module for it. Or
>> have I missed someting (wouldn't be the first time!)
> There's no direct equivalent to the whole of msvcrt.  The Unixy way to
> do stuff like that on the command line is usually curses.  But to make
> a long story short:  Unix evolved in a setting where there was often
> not a user at *THE* console, and users were often on devices such that
> it made sense to have all the line editing happen on the remote end, with
> the remote end sending a completed line once the user was done with all
> that stuff like backspaces.
> Unix programs that do stuff like this for tty input do exist, of course,
> but for the most part, they use an entire API designed for creating such
> utilities, rather than one or two specialized functions.  (Another part
> of the reason for this:  The Unix solution scales nicely to the case where
> the five people using your program will be doing so on physically
> different hardware terminals which don't use the same escape sequences
> for cursor movement.)

The difference is between "Hit <enter> to continue" (which we can do in 
portable Python) versus "Hit any key to continue" (which we cannot, and 
which also leads to the joke about people searching for the 'any' key 
;-). The equivalent contrast for GUIs is "Click OK to continue" versus 
"Click anywhere to continue" If having to click a specific area is okay 
for GUIs, having to hit a specific key for TUIs should be also.

Terry Jan Reedy

More information about the Python-list mailing list