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

jladasky at itu.edu jladasky at itu.edu
Mon Oct 24 14:14:05 EDT 2016


After reading this rather vague thread...

https://groups.google.com/forum/#!topic/comp.lang.python/FVnTe2i0UTY

... I find myself asking why Python doesn't include a standard, non-blocking keyboard input function.  I have often wanted one myself.  The only way that I've ever achieved this behavior is:

1) by restricting the user to pressing Ctrl-C while the program is running, and catching a KeyboardInterrupt; or

2) loading a heavyweight GUI like wxPython or PyQt, and using its event loop to intercept keyboard events.

I gather that non-blocking keyboard input functions aren't the easiest thing to implement.  They seem to depend on the operating system.  Still, ease of use is a primary goal of Python, and the need for this feature must be common.



More information about the Python-list mailing list