#!/usr/bin/python
import select
import sys
import os
import tty
import fcntl
poller = select.poll()
poller.register(sys.stdin, select.POLLIN)
tty.setcbreak(sys.stdin)
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
while True:
events = poller.poll(500)
if events:
for char in sys.stdin.read():
print ord(char)