A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import thread
|
||||
import time
|
||||
|
||||
|
||||
try:
|
||||
from msvcrt import getch
|
||||
except ImportError:
|
||||
def getch():
|
||||
import sys, tty, termios
|
||||
fd = sys.stdin.fileno()
|
||||
old_settings = termios.tcgetattr(fd)
|
||||
try:
|
||||
tty.setraw(sys.stdin.fileno())
|
||||
ch = sys.stdin.read(1)
|
||||
finally:
|
||||
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
||||
return ch
|
||||
|
||||
char = None
|
||||
|
||||
def keypress():
|
||||
global char
|
||||
char = getch()
|
||||
|
||||
thread.start_new_thread(keypress, ())
|
||||
|
||||
while True:
|
||||
if char is not None:
|
||||
print "Key pressed is " + char
|
||||
break
|
||||
print "Program is running"
|
||||
time.sleep(5)
|
||||
Loading…
Add table
Add a link
Reference in a new issue