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]=[], modifier_delay: float=None)¶ -
Holds down the given key or keycode if
down
isTrue
, or releases it if not. Integer keycodes and modifiers should be taken from module constants (e.g.,Code.DELETE
orModifier.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]=[], delay: float=None)¶ -
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
-
F13
- Code
-
F14
- Code
-
F15
- Code
-
F16
- Code
-
F17
- Code
-
F18
- Code
-
F19
- Code
-
F20
- Code
-
F21
- Code
-
F22
- Code
-
F23
- Code
-
F24
- Code
-
ALT
- Code
-
BACKSPACE
- Code
-
CAPS_LOCK
- Code
-
CONTROL
- Code
-
DELETE
- Code
-
DOWN_ARROW
- Code
-
END
- Code
-
ESCAPE
- Code
-
HOME
- Code
-
LEFT_ARROW
- Code
-
META
- Code
-
PAGE_DOWN
- Code
-
PAGE_UP
- Code
-
RETURN
- Code
-
RIGHT_ARROW
- Code
-
SHIFT
- Code
-
SPACE
- Code
-
UP_ARROW
-
class
autopy.key.
Modifier
¶ -
- Modifier
-
META
- Modifier
-
ALT
- Modifier
-
CONTROL
- Modifier
-
SHIFT