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
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | The key to press | |
| platform | Yes | Platform of the device |
Implementation Reference
- src/server/interactionTools.ts:548-557 (handler)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") });
- src/server/interactionTools.ts:715-721 (registration)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 );
- src/server/interactionTools.ts:41-44 (schema)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; }