Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
keyboard module question
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  datetime module question jacksfrustration 10 1,747 Jan-12-2024, 04:54 AM
Last Post: deanhystad
  Module not found question sighhhh12 0 1,502 Sep-09-2022, 05:43 AM
Last Post: sighhhh12
  Question on subprocess module. knoxvilles_joker 3 2,691 Apr-11-2021, 12:51 AM
Last Post: knoxvilles_joker
  keyboard module; must be root problem philipbergwerf 2 19,092 Apr-04-2021, 11:40 AM
Last Post: philipbergwerf
  keyboard module doesn't work in the microsoft version terminal of python. username 1 2,808 Feb-25-2021, 05:19 PM
Last Post: Larz60+
  Python - Keyboard module - Threading problem ppel123 1 3,077 Apr-13-2020, 04:49 PM
Last Post: deanhystad
  Keyboard Module Python - Suppress input while writing to window ppel123 0 2,801 Apr-08-2020, 02:51 PM
Last Post: ppel123
  Module googletrans 2.4.0 Question hlhp 0 2,580 Jun-17-2019, 03:50 PM
Last Post: hlhp
  Question about the Random Module Exsul 1 2,005 Mar-13-2019, 02:06 AM
Last Post: ichabod801
  import keyboard module doesn't get found - working on laptop but no on raspberry pi.. HANSJORG2 1 8,167 Mar-16-2018, 02:48 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020