press_key
Simulate keyboard key presses on a web page or specific element to trigger form submission, close modals, navigate focus, or execute shortcuts. Returns updated page state after the keypress.
Instructions
Dispatch a keyboard key press event on the page or a targeted element. Supports named keys (Enter, Escape, Tab, ArrowDown, Backspace) and character keys. Returns post-action page_state reflecting any DOM changes caused by the keypress. Use for form submission (Enter), closing modals (Escape), focus navigation (Tab), or keyboard shortcuts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key to press — use Playwright key names: "Enter", "Escape", "Tab", "ArrowDown", "ArrowUp", "Backspace", "Space", or single characters like "a". Modifier combos: "Control+a", "Shift+Tab". | |
| selector | No | Optional CSS selector or @eN ref to focus before pressing the key. If omitted, the key is dispatched to the currently focused element or the page. |