0

so basically i tried the following python script with both pyautogui and pynput (i will leave both codes below), what i want it to do is to hold the key "s" for 10 seconds, after that release it, but instead what it does is press the key once only, following is the code

Pynput

keyboard = Controller()


if __name__ == '__main__':
   keyboard.press("s")
   time.sleep(10)
   keyboard.release("s")

Pyautogui

if __name__ == '__main__':
    keyDown("s")
    time.sleep(10)
    keyUp("s")

thanks, and sorry for any incovinience

user132741
  • 15
  • 3
  • `keyboard.press("s")` does not mean what you think it does. Read the documentation. – BoarGules Apr 22 '22 at 14:07
  • Read the [documentation](https://pyautogui.readthedocs.io/en/latest/keyboard.html#the-press-keydown-and-keyup-functions) on what `press` does vs `keyDown` and `keyUp` – Jeremy Apr 22 '22 at 14:12
  • @Jeremy in the example i give above i was using pynput not pyautogui, but even with pyautogui keyDown function it only does one click instead of holding down the key – user132741 Apr 22 '22 at 14:15
  • @BoarGules i took a look at it, but i still dont know how to fix my issue, can you help me ? – user132741 Apr 22 '22 at 14:17
  • @Jeremy Yes! that worked perfectly thank you so much i ll close the question now – user132741 Apr 22 '22 at 14:22

0 Answers0