capturing ESC, page up/down in Python

J

jordilin

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
project.
 
T

Tim Roberts

jordilin said:
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
project.

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.
 
T

Terry Reedy

Much of Pygame is a wrapper for the SDL library. Would you be happier
using that part if it had been called PySDL?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top