browser_press_key
Press a specified key in a browser session to automate keyboard interactions during web automation tasks.
Instructions
Press key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- index.js:391-396 (registration)Registration and handler setup for 'browser_press_key'. It uses `proxyToolCall` to delegate the actual operation to a browser client.
server.tool('browser_press_key', 'Press key', { key: z.string() }, async (args) => { const check = requireActivePage(); if (check) return check; return proxyToolCall('browser_press_key', args); }); - index.js:209-235 (helper)Helper function that executes tool calls on the connected browser client.
async function proxyToolCall(toolName, args) { log(`[proxyToolCall] ${toolName} with args: ${JSON.stringify(args)}`); const { client } = await getOrCreateInstance(); log(`[proxyToolCall] got client for port ${assignedPort}`); // Update last used if (assignedPort && instances.has(assignedPort)) { instances.get(assignedPort).lastUsed = Date.now(); } try { log(`[proxyToolCall] Calling client.callTool...`); const result = await client.callTool({ name: toolName, arguments: args || {} }); log(`[proxyToolCall] Result type: ${typeof result}`); log(`[proxyToolCall] Result: ${JSON.stringify(result).slice(0, 500)}`); // The SDK returns { content: [...], isError?: boolean } // We need to return this same format if (result && result.content) { return result; } // Fallback: wrap in content array if needed return { content: [{ type: 'text', text: JSON.stringify(result) }] }; } catch (error) {