pilot_press_key
Press keyboard keys or key combinations on web pages to interact with forms, navigate fields, close modals, or execute shortcuts.
Instructions
Press a keyboard key or key combination on the page. Use when the user wants to press Enter to submit a form, Tab to move between fields, Escape to close a modal, ArrowDown to navigate a list, or use any keyboard shortcut.
Parameters:
key: Key name or combination (e.g., "Enter", "Tab", "Escape", "ArrowDown", "Backspace", "Shift+Enter", "Control+a")
Returns: Confirmation of the key pressed.
Errors:
"Unknown key": The key name is not recognized. Use standard Playwright key names (see docs.playwright.dev/key-input).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key name (e.g. Enter, Tab, Escape, ArrowDown, Shift+Enter) |
Implementation Reference
- src/tools/interaction.ts:263-293 (handler)The handler function for the pilot_press_key tool. It uses Playwright's keyboard.press() to send a key press to the page, or sends a 'press' command via the browser extension if one is active.
server.tool( 'pilot_press_key', `Press a keyboard key or key combination on the page. Use when the user wants to press Enter to submit a form, Tab to move between fields, Escape to close a modal, ArrowDown to navigate a list, or use any keyboard shortcut. Parameters: - key: Key name or combination (e.g., "Enter", "Tab", "Escape", "ArrowDown", "Backspace", "Shift+Enter", "Control+a") Returns: Confirmation of the key pressed. Errors: - "Unknown key": The key name is not recognized. Use standard Playwright key names (see docs.playwright.dev/key-input).`, { key: z.string().describe('Key name (e.g. Enter, Tab, Escape, ArrowDown, Shift+Enter)') }, async ({ key }) => { await bm.ensureBrowser(); try { const ext = bm.getExtension(); if (ext) { await bm.extSend('press', { key }); bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Pressed ${key}` }] }; } await bm.getPage().keyboard.press(key); bm.resetFailures(); return { content: [{ type: 'text' as const, text: `Pressed ${key}` }] }; } catch (err) { bm.incrementFailures(); return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } ); - src/tools/register.ts:73-87 (registration)The registration entry point. registerAllTools calls registerInteractionTools, which contains the tool definition.
export function registerAllTools(server: McpServer, bm: BrowserManager, profile: ToolProfile = 'full'): void { const allowed = PROFILE_TOOLS[profile]; const effectiveServer = allowed ? createFilteredServer(server, allowed) : server; registerNavigationTools(effectiveServer, bm); registerSnapshotTools(effectiveServer, bm); registerInteractionTools(effectiveServer, bm); registerPageTools(effectiveServer, bm); registerInspectionTools(effectiveServer, bm); registerVisualTools(effectiveServer, bm); registerTabTools(effectiveServer, bm); registerSettingsTools(effectiveServer, bm); registerIframeTools(effectiveServer, bm); registerAutomationTools(effectiveServer, bm); } - src/tools/register.ts:21-31 (registration)pilot_press_key is registered as part of the CORE_TOOLS set, making it available in all profiles (core, standard, full).
const CORE_TOOLS = new Set([ 'pilot_navigate', 'pilot_snapshot', 'pilot_snapshot_diff', 'pilot_click', 'pilot_fill', 'pilot_type', 'pilot_press_key', 'pilot_wait', 'pilot_screenshot', ]); - src/tools/interaction.ts:275-275 (schema)The input schema defines a single required string parameter 'key' for the key name or combination.
{ key: z.string().describe('Key name (e.g. Enter, Tab, Escape, ArrowDown, Shift+Enter)') },