Press a hardware button, navigation key, or Android keycode.
Usage
android input key [-h] [--alt] [--ctrl] [--shift] <key>
Options
--alt- Press key with Alt modifier.--ctrl- Press key with Ctrl modifier.-h,--help- Shows the help message for the specified command.--shift- Press key with Shift modifier.
input options:
--device=PARAM- Device serial number or emulator ID (as reported by 'adb devices').
android options:
--sdk=PARAM- Path to the Android SDK.-v,--verbose- Enable verbose output for troubleshooting.-V,--version- Print version information and exit.
Positional arguments
<key>- Key name (for example, back, home, enter, dpad-center, assist) or Android keycode
Common key names (aliases in parentheses):
- Navigation & Editing: back, home, recents (overview), menu, enter (return), tab, esc (escape), del (backspace), forward-del, space, page-up, page-down, move-home, move-end, cut, copy, paste, all-apps
- D-pad: dpad-up, dpad-down, dpad-left, dpad-right, dpad-center
- System & Audio: power (lock), sleep, wakeup, soft-sleep, volume-up, volume-down, volume-mute (mute), mic-mute, assist, voice-assist, search, camera, call, endcall, headset-hook (headsethook), notification, settings, brightness-up, brightness-down, sysrq (screenshot)
- Media: media-play-pause, media-play, media-pause, media-stop, media-next, media-previous, media-rewind, media-fast-forward
- Wear & Rotary: stem-primary, stem-1, stem-2, stem-3, navigate-previous, navigate-next, navigate-in, navigate-out
- TV: channel-up, channel-down, guide, bookmark, captions, info, tv-input, tv-power
Any other Android KeyEvent name is also accepted and resolved on the device, with or without the KEYCODE_ prefix (for example, zoom-in or KEYCODE_ZOOM_IN). Number keys need the prefix (KEYCODE_0), because a bare number is sent as a raw keycode. Names are case-insensitive and accept - or _.
Note that power (lock) toggles screen state while sleep and soft-sleep put the device to sleep, and mic-mute mutes the microphone while volume-mute (mute) mutes media volume
Description
android input key sends a hardware button, navigation key, or integer Android
keycode to a connected device or emulator.
Examples
Press the device Back button:
android input key back
Press D-pad center:
android input key dpad-center
Press the Wear OS primary stem button:
android input key stem-primary
Send a raw Android keycode (for example, 99 for KEYCODE_BUTTON_X):
android input key 99