browser_press_key
Simulate keyboard key presses during browser automation to interact with web elements, trigger actions, or navigate pages using Playwright's automation capabilities.
Instructions
Press a key on the keyboard
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Name of the key to press or a character to generate, such as `ArrowLeft` or `a` |
Implementation Reference
- src/tools/keyboard.ts:33-49 (handler)The handler function that executes the browser_press_key tool logic. It presses the specified key on the current browser tab's page using Playwright's keyboard.press method, generates accompanying code snippet, and returns an action object with network wait.handle: async (context, params) => { const tab = context.currentTabOrDie(); const code = [ `// Press ${params.key}`, `await page.keyboard.press('${params.key}');`, ]; const action = () => tab.page.keyboard.press(params.key); return { code, action, captureSnapshot, waitForNetwork: true }; },
- src/tools/keyboard.ts:23-31 (schema)JSON schema definition for the browser_press_key tool, including name, title, description, Zod input schema requiring a 'key' string, and destructive type.schema: { name: 'browser_press_key', title: 'Press a key', description: 'Press a key on the keyboard', inputSchema: z.object({ key: z.string().describe('Name of the key to press or a character to generate, such as `ArrowLeft` or `a`'), }), type: 'destructive', },
- src/tools/keyboard.ts:52-54 (registration)Exports the pressKey tool factory as the default export, registering it to be included in the tools list when imported.export default (captureSnapshot: boolean) => [ pressKey(captureSnapshot), ];