can python do some kernel stuff?

Ivan Illarionov ivan.illarionov at gmail.com
Fri May 23 15:42:03 EDT 2008


On 23 май, 22:32, Jimmy <mcknight0... at gmail.com> wrote:
[...]
> however, how can I just simply know a key is pressed?

If you are on Linux, use XLib
http://python-xlib.sourceforge.net/

You need to catch the KeyPress or KeyRelease X events.
while 1:
    ev = display.next_event()
    if ev.type == X.KeyPress:
        key_code = ev.detail
        ....
    ....

Ivan




More information about the Python-list mailing list