send_key
Simulate keyboard events in Firefox browser automation. Input specific keys, modifiers, and selectors to control browser interactions programmatically via the MCP server.
Instructions
Send keyboard events
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| modifiers | No | ||
| repeat | No | ||
| selector | No | ||
| tabId | No |
Implementation Reference
- index-multi-debug.js:1101-1131 (handler)The primary handler function for the 'send_key' MCP tool. Focuses optional selector, builds keypress with modifiers, repeats presses with delays, and returns confirmation.async sendKey(args) { this.ensureBrowserRunning(); const { key, selector, modifiers = [], repeat = 1, tabId } = args; const page = this.getPage(tabId); // If selector is provided, focus the element first if (selector) { await page.focus(selector); } // Build modifier string for Playwright const modifierString = modifiers.length > 0 ? modifiers.join('+') + '+' : ''; const fullKey = modifierString + key; // Press the key the specified number of times for (let i = 0; i < repeat; i++) { await page.keyboard.press(fullKey); // Small delay between repeated presses to ensure they register if (repeat > 1 && i < repeat - 1) { await new Promise(resolve => setTimeout(resolve, 50)); } } return { content: [{ type: 'text', text: `Sent key '${fullKey}'${repeat > 1 ? ` ${repeat} times` : ''}${selector ? ` to element '${selector}'` : ''} in tab '${tabId || this.activeTabId}'` }] }; }
- index-multi-debug.js:129-139 (schema)Input schema for 'send_key' tool defining parameters: key (required), selector, modifiers (array), repeat (default 1), tabId.inputSchema: { type: 'object', properties: { key: { type: 'string' }, selector: { type: 'string' }, modifiers: { type: 'array', items: { type: 'string' } }, repeat: { type: 'number', default: 1 }, tabId: { type: 'string' } }, required: ['key'] }
- index-multi-debug.js:413-414 (registration)Dispatch registration in CallToolRequestSchema handler switch statement, routing 'send_key' calls to this.sendKey(args).case 'send_key': return await this.sendKey(args);
- index-multi-debug.js:126-140 (registration)Tool registration in ListToolsRequestSchema response, including name, description, and full input schema.{ name: 'send_key', description: 'Send keyboard events', inputSchema: { type: 'object', properties: { key: { type: 'string' }, selector: { type: 'string' }, modifiers: { type: 'array', items: { type: 'string' } }, repeat: { type: 'number', default: 1 }, tabId: { type: 'string' } }, required: ['key'] } },