How to print/detect the scancode of a pressed key in pygame?
If I do this:
for event in pygame.event.get():
print event
It prints out:
<Event(2-KeyDown {'scancode': 1, 'key': 115, 'unicode': u's', 'mod': 0})>
<Event(3-KeyUp {'scancode': 1, 'key': 115, 'mod': 0})>
but how can I get it to print out the scancode part? e.g. prints out 1
when I press d
.
I tried this:
for event in pygame.event.get():
print event["scancode"]
which throws a error message because is not really a dictionary data structure.