Skip to content

Instantly share code, notes, and snippets.

@Peaches491
Created June 18, 2019 05:10
Show Gist options
  • Save Peaches491/e0017ce55699a485b776107efc87ec21 to your computer and use it in GitHub Desktop.
Save Peaches491/e0017ce55699a485b776107efc87ec21 to your computer and use it in GitHub Desktop.
Code to print keyboard keycodes for debugging keystroke delays
#! /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