Forrest logo
back to the adb tool

adb-shell:tldr:92364

adb-shell: Trigger a key event.
$ adb shell input keyevent ${keycode}
try on your machine

The command "adb shell input keyevent ${keycode}" is used in Android Debug Bridge (ADB) to send a key event to a connected Android device or emulator.

Here's how the command works:

  1. "adb" is the command-line tool used to interact with Android devices or emulators through a computer.

  2. "shell" is an ADB command that allows executing commands directly on the Android device's shell.

  3. "input" is a command group that deals with simulating user input on the device, including taps, swipes, and key events.

  4. "keyevent" is a sub-command of "input" used to send key events to the device. It simulates pressing a physical key on the device, such as the volume up/down or power button.

  5. "${keycode}" is a placeholder for the actual keycode value you want to input. The keycode represents a specific physical or virtual key on the Android device.

For instance, if you want to simulate pressing the Back button, you can use "adb shell input keyevent 4" since the back button's keycode is 4. Similarly, the Home button's keycode is 3, Volume Up is 24, Volume Down is 25, etc.

In summary, the command "adb shell input keyevent ${keycode}" is used to programmatically simulate pressing a specific key on an Android device or emulator using ADB.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the adb tool