capturing ESC, page up/down in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jordilin

    #1

    capturing ESC, page up/down in Python

    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.
  • Tim Roberts

    #2
    Re: capturing ESC, page up/down in Python

    jordilin <jordilin@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, timr@probo.com
    Providenza & Boekelheide, Inc.

    Comment

    • Terry Reedy

      #3
      Re: capturing ESC, page up/down in Python

      jordilin <jordilin@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?

      Comment

      Working...