press_key
Dispatch a keyboard key press event on a page or targeted element. Use named keys like Enter or Escape for form submission, closing modals, or keyboard shortcuts. Returns updated page state.
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". | |
| widen | No | When true, return the full-page diff instead of scoping to the interacted container. Default: false. | |
| 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. |