browser_press_key
Simulate keyboard key presses during automated web accessibility scans to test and verify WCAG compliance, ensuring interactions are accessible to all users.
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:37-46 (handler)The handler function that implements the core logic of the 'browser_press_key' tool by pressing the specified key using the Playwright page.keyboard.press method.handle: async (tab, params, response) => { response.setIncludeSnapshot(); response.addCode(`// Press ${params.key}`); response.addCode(`await page.keyboard.press('${params.key}');`); await tab.waitForCompletion(async () => { await tab.page.keyboard.press(params.key); }); }, });
- src/tools/keyboard.ts:27-35 (schema)The Zod schema definition for the 'browser_press_key' tool, specifying input as a 'key' string and marking it as 'destructive'.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.ts:38-56 (registration)The 'browser_press_key' tool is registered as part of the 'keyboard' tools spread into the central 'allTools' array, which is filtered and provided to the MCP server backend.export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...form, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ...verify, ];