Questions tagged [keyboard-python]

Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more. This tag is for use with questions that involve the Python "keyboard" module. For more general keyboard-related topics, please use the "keyboard" tag.

Homepage: https://github.com/boppreh/keyboard

15 questions
6
votes
3 answers

How to "send keys" to a canvas element for longer duration?

My aim: I am trying to make a python bot to win chrome's dino game. The game allows 2 types of jumps: short jumps long jumps Using main_body.send_keys(Keys.SPACE) (as shown in the code below) gives short jumps. My problem: I am having difficulty…
2
votes
1 answer

Why is my code looping twice when using keyboard?

I am writing code to alert the user when a specific string of numbers is entered. The code runs seems to run as intended but outputs "1122334455" when it should give me "12345": import sys sys.path.append('..') import keyboard line = '' ISBN10 =…
Cai Allin
  • 307
  • 2
  • 11
1
vote
2 answers

How to make python play a mouse events recording only WHILE left key is pressed?

I'm new to python and I'm trying to learn how to use the mouse and keyboard modules. I am trying to write some code that plays a recording while I'm holding left click, I think the issue is that this may be only part of the recording depending on…
apex
  • 19
  • 2
0
votes
2 answers

Are keyboard library and tkinter compatible?

I am trying to control the values of variables using the arrow keys on my keyboard to move a square around live on a tkinter canvas. I have no error message but when i run it Python 3.11, the canvas pops up but nothing happens when i press the…
0
votes
1 answer

Why is the GSpread RGB Color Scheme Inaccurate?

I am working on a project where I am trying to create a Pong-like game in Google sheets, using the spread library. However, I am not sure if this is a glitch, but the color coding of GSpread seems to be off. import gspread from…
San__
  • 11
  • 2
0
votes
0 answers

ImportError in python keyboard library

I need to use from Keyboard library in python. I installed with "sudo pip3 install keyboard" and if I do pip list keyboard appears. when I run the Programm, I have Error. Error is: "ImportError: you must be root to use this library on linux" Why is…
0
votes
0 answers

Longer process time when using hotkey

I have a Tkinter Frame with a tksheet (https://github.com/ragardner/tksheet, version: 30th June 2021) (actully 8 tksheets on 8 tabs). When I refresh the sheet(s) (clear content and fill it again) with the button, the process time is very low and you…
Garly San
  • 21
  • 2
0
votes
1 answer

Python Keyboard Module - import not working

I'm trying to use the keyboard module, but when I import it, I'm receiving a problem. import keyboard However, I get this error File "c:/Users/P/Code/test.py", line 1, in import keyboard File…
0
votes
1 answer

How would I tell if my user has focus on the terminal?

I am creating a chat room application using a CLI over a GUI, and I am on windows so I just use the default terminal in command prompt to run my code. My program detects individual key presses and then adds them to a list in my data class, which,…
0
votes
0 answers

Threaded code not giving output for some reason (pynput)

I'm testing this code from this response However I'm getting nothing in my output! Does anyone know why? My goal is to have a loop start when a key is pressed down and end when it's released. For some reason I can't get it to work. from…
0
votes
1 answer

Python enter key press, keyboard module

When using python with the keyboard module is there a way I can use enter to execute something within a program?
0
votes
0 answers

Python program stops in middle (linux mint)

#!/usr/bin/env python3 # -*- coding: utf-8 -*- import time import clipboard import webbrowser from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer import keyboard Bot = ChatBot('Bot') trainer =…
0
votes
1 answer

Python Keyboard Library is unable to differentiate between 'down' and 'right+down'

This is my code: import keyboard as kb def key_selected(): if kb.is_pressed('shift+s+down'): return 'True1' elif kb.is_pressed('shift+s+right+down'): return 'True2' else: return 'NOTHING' while…
Saat
  • 15
  • 4
-1
votes
1 answer

How to highlight text and paste in place with Python keyboard

I am trying to understand the behavior I am seeing from running my script below and how I can get my desired outcome. Basically I'm using keyboard.add_word_listener() to run a function when the string "test" is typed. It should select the tab…
Cave Johnson
  • 6,499
  • 5
  • 38
  • 57
-3
votes
3 answers

How can i get it to increment and print whenever i press the key, not just once?

With the below program, whenever I press the "a" key, the keypresses variable increments by 1. The problem is, if I don't immediately let go fo the key, the keypresses variable continues to increment by 1. How can I get it to increment (and print)…