Articles ā Python ā Keyup And Keydown Function In Pyautogui
Keyup And Keydown Function In Pyautogui
Purpose
- Keyup function invokes pressing a key on the keyboard.
- Keydown function invokes releasing a key on the keyboard.
Example
- Press CTRL down.
- Press SHIFT down.
- Press āNā.
- Release CTRL key.
- 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")
Click to Enlarge