擅长:python、mysql、java
<p>正如Nick D<a href="https://stackoverflow.com/questions/1550273/counting-all-the-keys-pressed-and-what-they-are-python/1550298#1550298">points out</a>,在Windows上,<a href="http://pypi.python.org/pypi/pyHook/1.4/" rel="nofollow noreferrer">PyHook library</a>可以工作。在</p>
<p>在Linux上,<a href="http://python-xlib.sourceforge.net/" rel="nofollow noreferrer">Python X Library</a>允许您访问X服务器上的按键。在</p>
<p>使用这两个库的一个很好的例子是<a href="http://pykeylogger.wiki.sourceforge.net/" rel="nofollow noreferrer">pykeylogger</a>。它是开源的;请参见<a href="http://www.koders.com/python/fidC2A13EA85A1B5C971E93300F93766F58F52A766D.aspx?s=timer" rel="nofollow noreferrer">^{<cd1>}</a>以获取相关的X库调用。在</p>
<p>Linux中的一个较低级别的选项是直接从<code>/dev/input/*</code>读取。<a href="http://svn.navi.cx/misc/trunk/python/evdev/evdev.py" rel="nofollow noreferrer">evdev (ctypes)</a>和{a7}模块可能对您有所帮助;但是我对它们了解不多。在</p>