Created
December 31, 2020 18:37
-
-
Save mcprat/111173f85fb1ff70eb00c74d023937c6 to your computer and use it in GitHub Desktop.
Windows python keyboard scan code script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import msvcrt | |
print('Press key to output Windows keyboard scan codes (Ctrl + Break to quit): ', end='\n\n', flush=True) | |
while True: | |
key = msvcrt.getwch() | |
if ord(key) in (0, 224): | |
ext = msvcrt.getwch() | |
else: | |
ext = None | |
print(ord(key), end=' ', flush=True) | |
if ext != None: | |
print(ord(ext), end='', flush=True) | |
print('\r') | |
print('in hex:') | |
print(hex(ord(key)), end=' ', flush=True) | |
if ext != None: | |
print(hex(ord(ext)), end='\n\n', flush=True) | |
print('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment