Why doesn't Python include non-blocking keyboard input function?

Chris Angelico rosuav at gmail.com
Fri Oct 28 08:28:37 EDT 2016


On Fri, Oct 28, 2016 at 11:12 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> The only specification he has given is reference to the BASIC INKEY$
> variable.  I don't know how consistent this was across different BASICs.  I
> looked in Microsoft's GW-BASIC reference and it says that it returns '',
> 'x', or '0x'.  This latter represents an extended code "described in
> Appendix C'.  However, Appendix C only lists the standard ASCII codes 000 to
> 128.  So I do not know what else was available and would not know from this
> book how to emulate GW-BASIC INKEY$.

The return values from INKEY$ are CHR$(0) + "H" for up-arrow, "P" for
down-arrow, and I think "K" and "L" for left and right. F1 is CHR$(0)
+ ";", and the next nine function keys are the subsequent ASCII
characters (";<=>?@ABCD"), although F11 and F12 are different, and I
don't remember what they are. The codes don't really have any meaning
in ASCII - they're just the scan codes, as represented in strings.
(CHR$(0) is equivalent to "\0" in saner languages.)

This is from memory, but I spent a *ton* of time in BASIC in my
earlier days, and there are things you never forget :)

ChrisA



More information about the Python-list mailing list