Keyboard¶
Keyboard sends keys to the currently focused window.
Keyboard
¶
Send keystrokes to the currently focused window.
Key syntax follows pywinauto conventions::
Keyboard.press("^a") # Ctrl+A — select all
Keyboard.press("^s") # Ctrl+S — save
Keyboard.press("{ENTER}") # Enter key
Keyboard.press("+{F10}") # Shift+F10 — context menu
Keyboard.type("Hello World") # type plain text with spaces
Keyboard.hotkey("ctrl", "c") # Ctrl+C — copy
Special key tokens: {ENTER}, {TAB}, {ESC}, {BACK},
{DELETE}, {F1}…{F12}, {UP}, {DOWN}, {HOME}, {END}.
Modifiers: ^ ctrl, + shift, % alt.
Source code in src\dolphin_desktop\_keyboard.py
Usage¶
from dolphin_desktop import Keyboard
Keyboard.press("^s") # Ctrl+S
Keyboard.press("{ENTER}") # Enter
Keyboard.type("Hello World") # plain text
Keyboard.hotkey("ctrl", "c") # Ctrl+C
Key Notation¶
Keyboard.press() uses pywinauto send_keys notation.
| Notation | Key |
|---|---|
{ENTER} |
Enter |
{TAB} |
Tab |
{ESC} |
Escape |
{BACK} |
Backspace |
{DELETE} |
Delete |
{UP}, {DOWN}, {LEFT}, {RIGHT} |
Arrow keys |
{HOME}, {END} |
Home / End |
{F1} ... {F12} |
Function keys |
^ |
Ctrl modifier |
% |
Alt modifier |
+ |
Shift modifier |