Skip to main content
Glama

browser_key_press

Press keyboard keys during web browser automation to interact with web elements, submit forms, navigate interfaces, and perform keyboard shortcuts in automated testing workflows.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., 'Enter', 'Tab', 'a', etc.)

Implementation Reference

  • Registers the 'browser_key_press' tool using server.tool(), defines input schema for 'key', and provides the handler function that instantiates ActionService and calls pressKey(key).
    server.tool( 'browser_key_press', 'Press a key on the keyboard', { key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"), }, async ({ key }) => { try { const driver = stateManager.getDriver(); const actionService = new ActionService(driver); await actionService.pressKey(key); return { content: [{ type: 'text', text: `Key '${key}' pressed` }], }; } catch (e) { return { content: [ { type: 'text', text: `Error pressing key: ${(e as Error).message}`, }, ], }; } } );
  • The core handler logic for pressing a key, using Selenium WebDriver actions to perform keyDown and keyUp on the specified key.
    async pressKey(key: string): Promise<void> { const actions = this.driver.actions({ bridge: true }); await actions.keyDown(key).keyUp(key).perform(); }
  • Zod schema defining the input parameter 'key' as a string.
    key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"), },

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/pshivapr/selenium-mcp'

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