📜  树莓派键盘 python 输入 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.262000             🧑  作者: Mango

代码示例1
import tty, sys, termios

filedescriptors = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
x = 0
while 1:
  x=sys.stdin.read(1)[0]
  print("You pressed", x)
  if x == "r":
    print("If condition is met")
termios.tcsetattr(sys.stdin, termios.TCSADRAIN,filedescriptors)