Skip to content

Instantly share code, notes, and snippets.

@KitWallace
Created August 17, 2012 23:09
Show Gist options
  • Save KitWallace/3383365 to your computer and use it in GitHub Desktop.
Save KitWallace/3383365 to your computer and use it in GitHub Desktop.
Read the Labtec Presenter keys
#!/usr/bin/python
import sys
import tty
def read_key() :
tty.setcbreak(sys.stdin)
last = 0
while True :
code = ord(sys.stdin.read(1))
if (code== 53 and last==91) :
key = "left"
elif (code==98) :
key = "down"
elif (code==54) :
key = "right"
elif (code==49) :
key = "up"
else :
key = None
last=code
if not(key is None) :
yield key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment