Skip to main content
Glama

pressKey

Press hardware keys on mobile devices for automation testing. Simulate actions like home, back, menu, power, and volume controls on Android and iOS platforms.

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

  • The pressKey tool handler function. Creates a PressButton instance and executes it with the provided key, then returns a formatted JSON response.
    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: key (enum of hardware keys) and platform.
    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 using ToolRegistry.registerDeviceAware, providing name, description, schema, handler, and progress support.
    ToolRegistry.registerDeviceAware( "pressKey", "Press a hardware key on the device (Maestro equivalent of pressButton)", pressKeySchema, pressKeyHandler, true // Supports progress notifications );
  • TypeScript interface defining the PressKeyArgs type used by 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