def _handle_keyboard_message(self):
data = None
if sys.platform in ['linux', 'darwin']:
import select
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
data = sys.stdin.readline().rstrip()
elif sys.platform == 'win32':
import msvcrt
if msvcrt.kbhit():
data = msvcrt.getch().decode('utf-8')
if data == '\r':
# Enter is pressed
data = self.__q_kb
self.__q_kb = ''
else:
print(data)
self.__q_kb += data
data = None
else:
pass
return data
## Get the data message which was queued earlier.
评论列表
文章目录