By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,588 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,588 IT Pros & Developers. It's quick & easy.

capturing ESC, page up/down in Python

P: n/a
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.
Oct 26 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jordilin <jo******@gmail.comwrote:
>
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.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 27 '08 #2

P: n/a
jordilin <jo******@gmail.comwrote:
>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.
Much of Pygame is a wrapper for the SDL library. Would you be happier
using that part if it had been called PySDL?

Oct 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.