views:

102

answers:

2

I'd like to create a map of the number of presses for every key for a project I'm working on.

I'd like to do this with a Python module. Is it possible to do this in any way?

+1  A: 

On Windows, a possible solution is to install Python for Windows extensions and use the PyCWnd.HookAllKeyStrokes

Nick D
+1  A: 

As Nick D points out, on Windows, the PyHook library would work.

On Linux, the Python X Library gives you access to key-presses on the X-server.

A good example of the use of both libraries is pykeylogger. It's open source; see pyxhook.py for example for the relevant X library calls.

A lower level option in Linux is to read directly from /dev/input/*. The evdev module may help you here; I don't know much about it this though.

ire_and_curses