how to capture key pressing

Discussion in 'Python' started by billie, Oct 10, 2005.

  1. billie

    billie Guest

    Hi all. I'm searching for a module that permit me to costantly log every key
    pressed on the keyboard and eventually assign it a function (e.g. when "esc"
    is pressed: exit program").
     
    billie, Oct 10, 2005
    #1
    1. Advertising

  2. Hi,

    Look at curses.

    Philippe


    billie wrote:

    > Hi all. I'm searching for a module that permit me to costantly log every
    > key pressed on the keyboard and eventually assign it a function (e.g. when
    > "esc" is pressed: exit program").
     
    Philippe C. Martin, Oct 10, 2005
    #2
    1. Advertising

  3. billie

    billie Guest

    > Look at curses.

    I was searching for something portable on multiple platforms.
    Curses doesn't work on Windows.
     
    billie, Oct 10, 2005
    #3
  4. billie

    Tim Roberts Guest

    "billie" <> wrote:
    >
    >> Look at curses.

    >
    >I was searching for something portable on multiple platforms.


    Keyboard access is not portable. It is quite system-specific, even in C.

    >Curses doesn't work on Windows.


    Sure it does. You can find curses implementations for Windows. However,
    it depends on what you are planning to do. If all you want to do is wait
    for one character and print it, it's not too hard to have separate schemes
    for separate systems:

    C:\Data\PyTools>python
    Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import msvcrt
    >>> msvcrt.getch()

    '\x1b'
    >>>


    (I pressed "escape" after the second "enter".)
    --
    - Tim Roberts,
    Providenza & Boekelheide, Inc.
     
    Tim Roberts, Oct 11, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mg
    Replies:
    5
    Views:
    1,034
    Vikram.NET
    Jul 14, 2003
  2. Cindy
    Replies:
    2
    Views:
    11,365
    Charlie Nilsson [MSFT]
    Mar 3, 2004
  3. Megha Vishwanath
    Replies:
    2
    Views:
    9,852
    tutorialsmaster
    Oct 2, 2009
  4. Kreedz
    Replies:
    8
    Views:
    417
    Graham Fawcett
    Sep 22, 2005
  5. HopfZ
    Replies:
    0
    Views:
    295
    HopfZ
    Jan 8, 2007
Loading...

Share This Page