Skip to content

getevent | Cheatsheet

getevent is a command-line tool that allows you to capture and display input events generated by input devices on an Android device. With 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 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
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 sendevent

Filter events by device

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

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
getevent | grep --line-buffered EV_ABS
```

=== "Capture key events" ===

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

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

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

Dump all input events to a file

getevent > /path/to/events.txt