Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

pressKey

Simulate keyboard key presses during browser automation to interact with web elements, submit forms, or navigate pages programmatically.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., 'Enter', 'Escape', 'ArrowDown', etc.)

Implementation Reference

  • The core implementation of the pressKey tool handler in PlaywrightController, simulating key press using page.keyboard.press(key).
    async pressKey(key: string): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Pressing key', { key }); await this.state.page.keyboard.press(key); this.log('Key press complete'); } catch (error: any) { console.error('Press key error:', error); throw new BrowserError('Failed to press key', 'Check if the key name is valid'); } }
  • Tool schema definition for pressKey, specifying the input parameter 'key' as a required string.
    const PRESS_KEY_TOOL: Tool = { name: "pressKey", description: "Press a key on the keyboard", inputSchema: { type: "object", properties: { key: { type: "string", description: "Key to press (e.g., 'Enter', 'Escape', 'ArrowDown', etc.)" } }, required: ["key"] } };
  • src/server.ts:539-539 (registration)
    Registers the pressKey tool in the tools dictionary passed to the MCP server's capabilities.
    pressKey: PRESS_KEY_TOOL,
  • src/server.ts:834-845 (registration)
    MCP server request handler for callTool 'pressKey', dispatching to playwrightController.pressKey with input validation.
    case 'pressKey': { if (!args.key) { return { content: [{ type: "text", text: "Key is required" }], isError: true }; } await playwrightController.pressKey(args.key as string); return { content: [{ type: "text", text: "Key pressed successfully" }] }; }

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/jomon003/PlayMCP'

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