![]() |
keyboard module question - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: keyboard module question (/thread-33027.html) |
keyboard module question - DPaul - Mar-23-2021 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. 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 |