Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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 (ctypes) and evdev (c-api) modules may help you here; I don't know much about them though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top