capturing ESC, page up/down in Python

Tim Roberts timr at
Mon Oct 27 01:49:57 CET 2008

jordilin <jordilin at> wrote:
>Is there any way to capture the keyboard events ESC, page up (next
>page), page down (previous page) in Python?. I mean, how can I capture
>if user presses one of those keys in a terminal based application? I
>was thinking about pygame.key.get_pressed from the pygame module, but
>I don't feel really happy about importing pygame in a non related game

Are you talking about Windows or Unix?  It matters.

In Windows, if you don't need a bunch of other features, you should check
out the WConio package.  It has kbhit and getch functions that can do this.
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list