Mar-23-2021, 04:22 PM
Hi,
I installed the keyboard module for a simple task. I want the user to be able to input a letter representing a color.
This is a stripped down version of the app, but it shows the problem I have. Instead of accepting the user input (1 letter)
once it seems to perform a second loop, instead of waiting for the next letter. (At least it should work like that).
Why does it perform 2 loops, and not 7 or 1 ? If you are considering to run this, you may need to pip install keyboard.
Paul
I installed the keyboard module for a simple task. I want the user to be able to input a letter representing a color.
This is a stripped down version of the app, but it shows the problem I have. Instead of accepting the user input (1 letter)
once it seems to perform a second loop, instead of waiting for the next letter. (At least it should work like that).
Why does it perform 2 loops, and not 7 or 1 ? If you are considering to run this, you may need to pip install keyboard.
import keyboard
#valid input letters 'a','b','c'...etc
def user_input():
clr = keyboard.read_key(suppress=True)
return clr
while True:
clr = user_input()
print('color is', clr)thx,Paul
