def get_key(self, block=True, timeout=None):
if timeout:
check = select.select([sys.stdin], [], [], timeout)[0]
if len(check) == 0:
return None
ret = self.stdscrs[-1].getkey()
elif block:
ret = self.stdscrs[-1].getkey()
else:
self.stdscrs[-1].nodelay(1)
try:
ret = self.stdscrs[-1].getkey()
if ret == curses.ERR:
ret = None
except:
ret = None
finally:
self.stdscrs[-1].nodelay(0)
if len(ret) == 1:
if ord(ret) < 0x20:
ret = "^{}".format(chr(ord(ret) + ord('@')))
elif ord(ret) == 0x7f:
ret = "^?"
return ret
评论列表
文章目录