najprościej użyć pyhook:
import pythoncom, pyHook
def OnKeyboardEvent(event):
# block only the letter A, lower and uppercase
return (event.Ascii not in (ord('a'), ord('A')))
# create a hook manager
hm = pyHook.HookManager()
# watch for all mouse events
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
event ma tam wystarczająco swoich metod:
print ('MessageName:',event.MessageName)
print ('Message:',event.Message)
print ('Time:',event.Time)
print ('Window:',event.Window)
print ('WindowName:',event.WindowName)
print ('Ascii:', event.Ascii, chr(event.Ascii))
print ('Key:', event.Key)
print ('KeyID:', event.KeyID)
print ('ScanCode:', event.ScanCode)
print ('Extended:', event.Extended)
print ('Injected:', event.Injected)
print ('Alt', event.Alt)
print ('Transition', event.Transition)
ja na pythonie 3.5 właśnie w/w używałem, z połączeniem z pywin32 można zrobić wiele.
trochę się tym bawiłem i powiem, że jest dosyć intuicyjne