key — autopy module for working with the keyboard

This module contains functions for controlling the keyboard.

Functions

autopy.key.toggle(key: Any, down: bool, modifiers: List[Modifier])

Holds down the given key or keycode if down is True, or releases it if not. Integer keycodes and modifiers should be taken from module constants (e.g., key.K_DELETE or key.MOD_META). If the given key is a character, it is automatically converted to a keycode corresponding to the current keyboard layout.

autopy.key.tap(key: Any, modifiers: List[Modifier])

Convenience wrapper around toggle() that holds down and then releases the given key and modifiers.

autopy.key.type_string(string: str, wpm: float=None)

Attempts to simulate typing a string at the given WPM, or as fast as possible if the WPM is 0.

Constants

class autopy.key.Code
Code:F1
Code:F2
Code:F3
Code:F4
Code:F5
Code:F6
Code:F7
Code:F8
Code:F9
Code:F10
Code:F11
Code:F12
Code:ALT
Code:BACKSPACE
Code:CAPS_LOCK
Code:CONTROL
Code:DELETE
Code:DOWN_ARROW
Code:END
Code:ESCAPE
Code:HOME
Code:LEFT_ARROW
Code:PAGE_DOWN
Code:PAGE_UP
Code:RETURN
Code:RIGHT_ARROW
Code:SHIFT
Code:UP_ARROW
class autopy.key.Modifier
Modifier:META
Modifier:ALT
Modifier:CONTROL
Modifier:SHIFT