Пример #1
0
#Type two  upper case As
keyboard.press('A')
keyboard.release('A')
# or
#Executes a block with some keys pressed.    param keys: The keys to keep pressed.
with keyboard.pressed(Key.shift):  #组合按键
    keyboard.press('a')
    keyboard.release('a')

#type 'hello world '  using the shortcut type  method
#This method will send all key presses and releases necessary to type all characters in the string.
#param str string: The string to type.
keyboard.type('hello world')

keyboard.touch('&', True)
keyboard.touch('&', False)

keyboard.press(Key.print_screen)
keyboard.release(Key.print_screen)

with keyboard.pressed(Key.ctrl):  #组合按键
    keyboard.press('s')
    keyboard.release('s')

#keyboard listen
from pynput import keyboard

#alt_pressed、alt_gr_pressed、ctrl_pressed、shift_pressed