page.keyboard sends real keyboard input to the focused element. To type into a
particular element, use locator.fill()
or locator.press_sequentially(),
which focus it first.
keyboard.type()
Type text at the focus.
| Parameter | Type | Default | Description |
|---|---|---|---|
text | str | required | What to type. |
delay | float | None | None | Milliseconds between keys. |
keyboard.insert_text() is the same as type().
keyboard.press()
Press and release one key or chord.
| Parameter | Type | Default | Description |
|---|---|---|---|
key | str | required | A key name or one character, with modifiers joined by +. |
delay | float | None | None | Accepted for compatibility; a press is one stroke. |
Enter, Tab, Escape, Backspace, Delete,
ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp,
PageDown, F1 to F12. Modifiers are Control, Shift, Alt and Meta
(Ctrl works too). With a modifier, a letter is the key itself: Control+A is
Ctrl+A.
Raises InvalidArgsError for a chord that would act outside the page:
anything with Meta (the Windows key); Alt+F4, Alt+Tab, Alt+Escape,
Alt+Space, Control+Escape, Control+Shift+Escape; F11, F12 and the
developer tools chords Control+Shift+I, J and C; and the open, save and
print dialogs Control+O, Control+S, Control+Shift+P.
keyboard.down() and keyboard.up()
Not available. Raises UnsupportedError; use keyboard.press() with a chord
such as "Shift+Tab".