Created
June 18, 2019 05:10
-
-
Save Peaches491/e0017ce55699a485b776107efc87ec21 to your computer and use it in GitHub Desktop.
Code to print keyboard keycodes for debugging keystroke delays
This file contains 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
#! /usr/bin/env python2 | |
import sys | |
import termios | |
import tty | |
stdin_fd = sys.stdin.fileno() | |
old = termios.tcgetattr(stdin_fd) | |
try: | |
tty.setcbreak(sys.stdin) | |
while True: | |
print ord(sys.stdin.read(1)) | |
finally: | |
old[3] = old[3] | termios.ECHO | |
termios.tcsetattr(stdin_fd, termios.TCSADRAIN, old) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment