![](https://secure.gravatar.com/avatar/b684c02bab6c8d54c0c25c4b69ee1135.jpg?s=120&d=mm&r=g)
14 May
2009
14 May
'09
5:49 p.m.
On 13-May-09, at 9:27 PM, Zachary Pincus wrote:
Old-school alternative is to put the TTY into cbreak (aka "rare" mode, between "raw" and "cooked"), and capture a single key-hit. (Except that ^C still breaks, which is handy.) For windows, the C runtime has a similar getkey function.
Here's windows / posix code for that that I've assembled from various snippets online; note that the latter uses the well-known decorator module. I've also included an "iskeydown" function which I find useful in various situations...
Awesome, thanks! David