Skip to main content
Glama

browser_press_key

Simulate key presses in a web browser to automate interactions, such as typing text or navigating with keyboard shortcuts, using Playwright MCP for structured accessibility tasks.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesName of the key to press or a character to generate, such as `ArrowLeft` or `a`

Implementation Reference

  • The handler function for the 'browser_press_key' tool. It presses the specified key on the current browser tab's page using Playwright's keyboard.press method, generates accompanying code snippet, and configures snapshot capture.
    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 }; },
  • The schema definition for the 'browser_press_key' tool, specifying name, title, description, input schema (key parameter), 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.ts:41-41 (registration)
    Registration of keyboard tools (including 'browser_press_key') into the snapshotTools array.
    ...keyboard(true),
  • src/tools.ts:58-58 (registration)
    Registration of keyboard tools (including 'browser_press_key') into the visionTools array.
    ...keyboard(false),
  • Selects the appropriate tools array (including 'browser_press_key') based on config.vision for use in MCP server.
    const allTools = config.vision ? visionTools : snapshotTools;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Angeluis001/playwright-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server