press_key
Simulate pressing hardware or software keys on Android devices to automate navigation, volume control, power management, and menu access during testing or automation workflows.
Instructions
Press a hardware/software key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Key to press | |
| device_id | No | Device ID (optional if only one device) |
Implementation Reference
- src/index.ts:330-333 (handler)The MCP tool handler for "press_key" which calls the ADB helper.
async ({ key, device_id }) => { await adb.pressKey(KEYCODE_MAP[key], device_id); return { content: [{ type: "text", text: `Pressed: ${key}` }] }; }, - src/adb.ts:317-319 (handler)The ADB implementation of the pressKey logic.
async pressKey(keycode: number, deviceId?: string): Promise<void> { await this.exec(["shell", "input", "keyevent", String(keycode)], deviceId); } - src/index.ts:307-329 (schema)The input schema definition for the "press_key" tool.
{ key: z .enum([ "back", "home", "enter", "tab", "delete", "menu", "recent_apps", "volume_up", "volume_down", "power", "search", "dpad_up", "dpad_down", "dpad_left", "dpad_right", "dpad_center", ]) .describe("Key to press"), device_id: z.string().optional().describe("Device ID (optional if only one device)"), }, - src/index.ts:304-306 (registration)The registration of the "press_key" tool in the MCP server.
server.tool( "press_key", "Press a hardware/software key",