Articles ā†’ Python ā†’ Keyup And Keydown Function In Pyautogui

Keyup And Keydown Function In Pyautogui






Purpose


  1. Keyup function invokes pressing a key on the keyboard.
  2. Keydown function invokes releasing a key on the keyboard.

Example




  1. Press CTRL down.
  2. Press SHIFT down.
  3. Press ā€˜Nā€™.
  4. Release CTRL key.
  5. Release SHIFT key.


import pyautogui
import time

pyautogui.keyDown("ctrl")
time.sleep(1)
pyautogui.keyDown("shift")
time.sleep(1)
pyautogui.press("n")
time.sleep(4)
pyautogui.keyUp("ctrl")
time.sleep(1)
pyautogui.keyUp("shift")




Picture showing the output of the keyup and keydown function in pyautogui
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, May 29, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250