Skip to main content
Glama

browser_press_key

Simulate key presses in a browser environment using Playwright MCP, enabling automated interactions such as typing characters or navigating web pages via specified keyboard inputs.

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 that executes the tool logic by pressing the specified key using the page's keyboard API.
    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 }; },
  • Defines the tool schema including name, description, and input validation using Zod.
    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:42-42 (registration)
    Includes the keyboard tools (browser_press_key) in the snapshotTools array with captureSnapshot enabled.
    ...keyboard(true),
  • src/tools.ts:60-60 (registration)
    Includes the keyboard tools (browser_press_key) in the visionTools array without captureSnapshot.
    ...keyboard(false),

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/lewisvoncken/playwright-mcp'

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