Counting all the keys pressed and what they are (python)
I'd like to create a map of the number of presses for every k开发者_如何学运维ey 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?
On Windows, a possible solution is to install Python for Windows extensions and use the PyCWnd.HookAllKeyStrokes
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.
精彩评论