⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 raw_keyboard.py

📁 Most satellite dish actuators send a series of pulses to indicate their position. By counting pulse
💻 PY
字号:
# Get the keyboard into raw mode.import termios, sys, os,fcntldef UnBlock(fd) :  fl = fcntl.fcntl(fd, fcntl.F_GETFL, 0)  fl |= os.O_NONBLOCK  fcntl.fcntl(fd, fcntl.F_SETFL, fl)class UnixKeyboard :  "Raw input for the duration of the importer"  def __init__(self) :    self.fd = sys.stdin.fileno()    UnBlock(self.fd)    self.old = termios.tcgetattr(self.fd)    new = termios.tcgetattr(self.fd)    new[3] = new[3] & ~termios.ICANON & ~termios.ECHO    new[6][termios.VMIN] = 1    new[6][termios.VTIME] = 0    termios.tcsetattr(self.fd, termios.TCSANOW, new)  def getch(self):    ret = ""    try :      ret = os.read(self.fd, 1)    except OSError, info :      if info.errno==11 :        pass      else :        raise sys.exc_type, sys.exc_value    return ret  def __del__(self) :    import termios    termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)Keyboard = UnixKeyboard()if __name__ == "__main__" :    print "Running key echo program"  while True :    b = Keyboard.getch()    sys.stdout.write(b)    sys.stdout.flush()    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -