r/pythonhelp • u/Original_GumPum • Jun 07 '23
Holding a key down like on a real keyboard
Hello, I'm very new to coding and I want to make my program hold down a key like a person would on a keyboard.
I'm currently using pynput like
keyboard.press(button) time.sleep(random.uniform(3, 5)) keyboard.release(button)But it doesn't hold the key down. It's just one key press. And if I simulate it by using a loop, it still behave different then holding a key on a real keyboard.
Because holding a key on a real keyboard outputs one letter, then a small delay and then it starts printing the letters fast.
Anyone knows the soluion?
0
Jun 07 '23
[deleted]
1
u/Original_GumPum Jun 23 '23
Thanks for your help!
I'm not understanding what you mean with
def simulate_key_holding(key, hold_time): delay_between_presses = 0.1where it's getting called from, or am I blind?
1
u/RoyoDeBoyo Dec 26 '24
did you find a solution to this problem. I want to do exactly the same thing and can't find anything anywhere lol