Skip to main content
Glama

keyboard

Press keys or key combinations in a browser to automate typing, navigation, and form interactions during web automation tasks.

Instructions

Press a key or key combination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., "Enter", "Tab", "a")
modifiersNoModifier keys to hold
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Handler implementation for the 'keyboard' tool: registers the tool and provides the execution logic using Puppeteer's keyboard API to press modifiers and the key.
    server.tool( 'keyboard', 'Press a key or key combination', keyboardSchema.shape, async ({ key, modifiers, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; const mods = (modifiers ?? []) as KeyModifier[]; try { // Press modifier keys for (const mod of mods) { await page.keyboard.down(mod); } // Press the main key await page.keyboard.press(key as KeyInput); // Release modifier keys for (const mod of mods.reverse()) { await page.keyboard.up(mod); } return handleResult(ok({ pressed: true, key, modifiers: mods, })); } catch (error) { return handleResult(err(normalizeError(error))); } } );
  • Zod schema defining the input parameters for the 'keyboard' tool: key, optional modifiers, and optional tabId.
    export const keyboardSchema = z.object({ key: z.string().min(1).describe('Key to press (e.g., "Enter", "Tab", "a")'), modifiers: z.array(z.enum(['Alt', 'Control', 'Meta', 'Shift'])).optional().default([]).describe('Modifier keys to hold'), tabId: tabIdSchema, });
  • src/server.ts:29-29 (registration)
    Calls registerInputTools which includes the registration of the 'keyboard' tool.
    registerInputTools(server);
  • Type definition for keyboard modifier keys used in the keyboard tool.
    * Keyboard modifier keys */ export type KeyModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';

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/andytango/puppeteer-mcp'

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