1
#greenhouse monitor algorithm
import msvcrt
while not (msvcrt.kbhit() and .....): #I want to check whether the key pressed is <ESCAPE> or not
    sensor1=float(input("Please input the temperature of the green house: ")) 
    sensor2=float(input("Please input the oxygen level of the green house: "))

    if (sensor1>45):
        print("Warning. Temperature is too high")

    if (sensor2<0.19):
        print("Warning. Oxygen level is too low")

How do I check whether the key pressed is ESCAPE or not?

S.Ahmed
  • 191
  • 1
  • 4
  • 12

1 Answers1

0

You may want to use the select module (or msvcrt on Windows).

emmanuelsa
  • 657
  • 6
  • 9