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

Is there a way to distinguish pynput's keyboard input from actual physical key presses?

I am trying to write a script that will stay in a loop and infinitely type random characters using pynput's press and release functions. However, I am also trying to detect hotkeys (e.g. ctrl+alt+q to exit the script) to start, stop, and pause the…
0
votes
0 answers

Why Alt Gr combination works well but Shift only per one click

I'm working on something similar to a custom keyboard layout. I want to have working combinations of shift + key, alt gr + key and shift + alt gr + key. However as alt gr + key works pretty good, after shift + key program takes shift as released…
Werinl
  • 1
  • 2
0
votes
0 answers

keyboard.send('enter') doesn't work on 'Save As' pop-up window

I have a simple Python script that just clicks on already opened Browser window, preses 'Ctrl+s' and saves the page. It works until 'Save As' pop-up window appears, so in below code ctrl+s works but the last doesn't import keyboard,…
psmith
  • 1,769
  • 5
  • 35
  • 60
0
votes
0 answers

Python keyboard hotkey with toggling of the Scroll Lock

pre: I'm not familiar with the low level win32Api calls. I was testing a python script that binds a key to call a function and to toggle a Scroll Lock as an indicator that the key-remapping is ON with the keyboard module. Here is an example that it…
IgorZ
  • 1,125
  • 3
  • 20
  • 44
0
votes
2 answers

Autoclicker starts but doesn't pause unless it's killed

I'm new to python and I'm working on a small autoclicker that you can turn on & off using the letter 's', however when I press it the autoclicker starts but I can't turn it off unless I use the letter 'k' which is used to stop the program…
Frederick
  • 21
  • 2
0
votes
2 answers

Is there any way to detect a keypress that is executed programmatically?

I want to detect if a keypress was executed programmatically (not by user's physical press). Is there any way to do this? import mouse import keyboard import time keyboard.press("a") if keyboard.is_pressed('a'): print ("pressed") I assume…
kerz
  • 67
  • 6
0
votes
0 answers

how does "is_pressed" in keyboard&mouse module exactly work?

im trying to check if a keybutton or a mousebutton is pressed but 'is_pressed' gives me false. i dont think im doing anything wrong but is there something im missing? import mouse import keyboard import time class Test: def keytest(self): …
kerz
  • 67
  • 6
0
votes
1 answer

PyAutoGUI keyboard shortcut unexpectedly triggers Chrome's Ctrl+F (find in page) and Ctrl+O (open file). How to prevent this?

I'm using PyAutoGUI to listen for a keyboard shortcut, but when I press the shortcut keys, it triggers Google Chrome's Ctrl + F and Ctrl + O shortcuts to find in page and open a file. However, I do not want it to trigger Chrome's shortcuts. I only…
0
votes
1 answer

Can't run pyautogui on ubuntu

i want to use Pyautogui and Keyboard module at the same time (Using Python), but i can't do that. i have installed Keyboard module and Pyautogui module too, but when i try to run Pyautogui via root i get this error (sudo python3) raise…
Varsima
  • 31
  • 1
  • 6
0
votes
1 answer

Send Ctrl+Shift+(minus) in Python

I have a hopefully quick one for the experts here. I'm writing a script in python that will eliminate repetitive typing into a GL. It's mostly working, but I'm at a roadblock. Using the keyboard package, I'm trying to send ctrl+shift+(minus). I…
0
votes
0 answers

Python: script gets stuck on Keyboard.wait()

So it just breaks when holding down while holding down SHIFT ALT or CTRL While the function is running, When It does break I do try tapping SHIFT ALT and CTRL to see if they are stuck down and they aren't so I'm all out of ideas. import time import…
0
votes
0 answers

Why is Eevee.wav not playing

I'm trying to get the Eevee.wav to play when both the key is clicked and PetHappyTF is 1. Anytime I hit E it doesnt play. I know the audio is fine because when i remove the first if it works. so... SOS! #importing stuff from playsound import…
Pig Empire
  • 11
  • 1
0
votes
1 answer

python Keyboard library - no output, but no error message

I have the keyboard library running fine on one mac. On another mac, using the same commands, it runs without error, but there is no output. Any ideas? Sorry, no code to replicate other than: pip install keyboard import…
Prolle
  • 358
  • 1
  • 10
0
votes
0 answers

Create hotkeys with a for loop

I want to create multiline HotKeys in python with one single for loop. I have a list looking like this: import keyboard HotKey = [] while True: list = [] key = input() word = input() list .append(key,word) if key == -1: …
0
votes
2 answers

take count of how many times user pressed backspace key

I am trying to take count of how many times the user pressed the backspace key while giving input. I am using the following code but it doesn't seem like working for me any help would be appreciated TIA. word = input() count = 0 for letter in word: …