Skip to main content
Glama

pressKey

Simulate hardware key presses on Android or iOS devices for automated testing. Includes options for home, back, menu, power, and volume controls.

Instructions

Press a hardware key on the device (Maestro equivalent of pressButton)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesThe key to press
platformYesPlatform of the device

Implementation Reference

  • Handler function that executes the pressKey tool by delegating to PressButton.execute with the provided key.
    const pressKeyHandler = async (device: BootedDevice, args: PressKeyArgs, progress?: ProgressCallback) => { const pressButton = new PressButton(device); const result = await pressButton.execute(args.key, progress); return createJSONToolResponse({ message: `Pressed key ${args.key}`, observation: result.observation, ...result }); };
  • Zod schema defining the input arguments for the pressKey tool.
    export const pressKeySchema = z.object({ key: z.enum(["home", "back", "menu", "power", "volume_up", "volume_down", "recent"]) .describe("The key to press"), platform: z.enum(["android", "ios"]).describe("Platform of the device") });
  • Registration of the pressKey tool with the ToolRegistry, including name, description, schema, and handler.
    ToolRegistry.registerDeviceAware( "pressKey", "Press a hardware key on the device (Maestro equivalent of pressButton)", pressKeySchema, pressKeyHandler, true // Supports progress notifications );
  • TypeScript interface defining the shape of PressKeyArgs used in the handler.
    export interface PressKeyArgs { key: "home" | "back" | "menu" | "power" | "volume_up" | "volume_down" | "recent"; platform: Platform; }

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/zillow/auto-mobile'

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