Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

raspberry pi keyboard python input

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)
Source by www.circuitbasics.com #
 
PREVIOUS NEXT
Tagged: #raspberry #pi #keyboard #python #input
ADD COMMENT
Topic
Name
5+5 =