Skip to main content
Glama

browser_press_key

Simulate keyboard input by pressing a specified key, enabling browser automation and interaction with web pages through the Playwright MCP server.

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 implements the 'browser_press_key' tool. It adds code comments and executes page.keyboard.press(params.key) within the tab's waitForCompletion.
    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); }); },
  • Defines the schema for the 'browser_press_key' tool, including name, description, input schema for the 'key' parameter, and 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:36-52 (registration)
    Registers the 'browser_press_key' tool (imported from keyboard.js) by including it in the allTools array via spread operator.
    export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];

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/nzjami/mcpPlaywright'

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