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.
page.keyboard.type("Hello, world")
page.keyboard.press("Control+a")
page.keyboard.press("Backspace")

keyboard.type()

Type text at the focus.
keyboard.type(text, *, delay=None)
ParameterTypeDefaultDescription
textstrrequiredWhat to type.
delayfloat | NoneNoneMilliseconds between keys.
Characters a US keyboard has are pressed as keys, with Shift where needed. Other characters (accents, other scripts, emoji) are inserted at the focus in order with them, so mixed text comes out as written. keyboard.insert_text() is the same as type().

keyboard.press()

Press and release one key or chord.
keyboard.press(key, *, delay=None)
ParameterTypeDefaultDescription
keystrrequiredA key name or one character, with modifiers joined by +.
delayfloat | NoneNoneAccepted for compatibility; a press is one stroke.
Key names follow Playwright: 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".