Skip to content

getevent | Cheatsheet

adb shell getevent is a command-line tool that allows you to capture and display input events generated by input devices on an Android device. With adb shell getevent, you can monitor and analyze the raw input events, such as touch events, key events, and other input interactions, happening on the device in real-time.

This tool is particularly useful for debugging and understanding how the device processes user input. By utilizing adb shell getevent, you can gain insights into the low-level input events and enhance your understanding of the device's input system.

Record a series of events

=== "Recording" ===

```bash
adb shell getevent | grep --line-buffered ^/ | tee /tmp/android-touch-events.log
```
awk '{printf "%s %d %d %d\n", substr($1, 1, length($1) -1), strtonum("0x"$2), strtonum("0x"$3), strtonum("0x"$4)}' /tmp/android-touch-events.log | xargs -l adb shell sendevent

Filter events by device

You can filter the input events by specifying the device file using the -s option:

adb shell getevent -s /dev/input/event2

Capture specific input events

You can capture specific input events by filtering the output using grep:

=== "Capture touch events" ===

```bash
adb shell getevent | grep --line-buffered EV_ABS
```

=== "Capture key events" ===

```bash
adb shell getevent | grep --line-buffered EV_KEY
```

=== "Capture other input events" ===

```bash
adb shell getevent | grep --line-buffered EV_SYN
```

Dump all input events to a file

adb shell getevent > /path/to/events.txt