Hi all
I write a program to detect key press,but , why there is a *space*
before the character I typed.??
#!/usr/bin/env python
import sys
import tty
import termios
i = sys.stdin.fileno()
o = sys.stdout.fileno()
backup = termios.tcgetattr(i)
def loop():
while 1:
ch = sys.stdin.read(1)
print "->%s"%ch
if ch == 'q':break
try:
tty.setraw(i)
loop()
finally:
termios.tcsetattr(i, termios.TCSADRAIN, backup)