I was working on a keylogger to learn a bit about pyHook, but it seems like event.Ascii
gives me the wrong ASCII values. For example I get 0 for any symbol or number, 1 for A (should be 65), etc.
import pyHook, pythoncom
def OnKeyboardEvent(event):
key = chr(event.Ascii)
print(key)
return 0
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
I found a kind of a fix for it, which is using event.KeyID
instead of event.Ascii
. However, because of that I only get letters and numbers - symbols are totally wrong.
Is this a Python problem, or some kind of keyboard problem?