Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

pressKey

Simulate keyboard key presses in browser automation workflows. Specify the key (e.g., 'Enter', 'Escape') to execute actions like form submissions or navigation, enhancing interaction efficiency.

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 handler function that executes the pressKey tool logic using Playwright's page.keyboard.press(key) method.
    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'); } }
  • The input schema definition for the pressKey tool, specifying the required 'key' parameter.
    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:834-845 (registration)
    The registration and dispatch logic in the MCP callTool request handler that invokes the pressKey controller method.
    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