Questions tagged [python-keyboard]

A small Python library to hook global events, register hotkeys, simulate key presses and more.

A small Python library to hook global events, register hotkeys, simulate key presses and more. Available from pypi.org.

38 questions
0
votes
0 answers

How to implement the pressing and holding of a key until another action is performed?

I want to make a piece of code in which a key is pressed and held until another action is performed. Here is my code: ''' virtual steering wheel hold your hand as you hold steering wheel turn right turn left ''' import cv2 import mediapipe as…
0
votes
2 answers

Python keyboard module error: TypeError: 'NoneType' object is not callable

My code is: import keyboard pressed = "" def on_key_press(): print("Key pressed.") global pressed # Took me 1 hour to figure out this. if charset.chars.__contains__(keyboard.read_key()): print("processing slangs...") …
0
votes
1 answer

keyboard module does not detect key-press on the first event of Tkinter

Suppose you have this code. def test(widget): print(keyboard.is_pressed("shift")) t=tkinter.Tk() b=tkinter.scrolledtext.ScrolledText() b.bind("", test) b.pack() t.mainloop() Just on the very first try of holding shift and pressing…
Hormoz
  • 291
  • 1
  • 2
  • 7
0
votes
1 answer

Trying to control the specific location of the number 5 in a array by using arrow keys on my keyboard

I am trying to write a simple program that will allow me to control the location of the number 5 in an array. However, when I run the code the controls don't really work. Also, I'm trying to clear the terminal so that it only shows the current…
J R
  • 1
0
votes
4 answers

How to clear input while using keyboard module?

I am writing a text based game with Python and the library keyboard. At one point of my code I had to gather a number which I got by following code: if menu == "test": try: x = int(input("Enter a Number: ")) except ValueError: …
0
votes
1 answer

Keyboard library python3

I am trying to do a python script and while the script is running in the background I want it to listen at some buttons, the problem is that I can't even this simple program to get to work, I get segmentation fault 11. When I run it I use sudo…
-1
votes
2 answers

I am trying to create a start and stop button with a keyboard press

I am using the keyboard library to create a button that starts and stops with the press of a button and I keep getting errors this is the code while True: if keyboard.on_press('esc') == True: if start == 0: start = 1 …
-1
votes
2 answers

Looping until a specific key is pressed

I was trying to make a while loop which would stop running when a specific key is pressed. The problem is that the loop runs infinitely. My loop: import time import keyboard while (not keyboard.is_pressed("esc")): print("in loop...") …
Jermartyno
  • 43
  • 1
  • 7
1 2
3