LinuxCommandLibrary

evtest

Test input devices (e.g., keyboard, mouse)

TLDR

List all detected input devices

$ sudo evtest
copy

Display events from a specific input device
$ sudo evtest /dev/input/event[number]
copy

Grab the device exclusively, preventing other clients from receiving events
$ sudo evtest --grab /dev/input/event[number]
copy

Query the state of a specific key or button on an input device
$ sudo evtest --query /dev/input/event[number] [event_type] [event_code]
copy

SYNOPSIS

evtest [-h | -V | -g | -i | -q | -f | -t TYPE | --msc] /dev/input/eventN

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Print version information and exit

-g, --grab
    Grab device exclusively; events not forwarded to system

-i, --info
    Print device info (name, capabilities) and exit

-q, --query
    Query and print device info only (alias for -i)

-f, --flush
    Flush pending events before starting capture

-t TYPE, --type=TYPE
    Filter and show only events of specified TYPE (e.g., EV_KEY)

--msc
    Include miscellaneous (MSC) events in output

DESCRIPTION

evtest is a command-line utility for monitoring and testing raw input events from Linux kernel input devices, such as keyboards, mice, touchpads, joysticks, and touchscreens. It reads from /dev/input/event* files using the evdev interface and displays events in a readable format, including timestamps, event types (e.g., EV_KEY for keys, EV_REL for mouse movement), codes, and values.

This tool is essential for debugging input hardware, verifying driver functionality, calibrating devices, or analyzing event streams during development. To use it, identify the device with ls /dev/input/event*, ls /dev/input/by-id/, or cat /proc/bus/input/devices, then run evtest /dev/input/event0. Press Ctrl+C to exit. Events are printed continuously until interrupted.

Key features include exclusive grabbing to block system access, filtering by event type, and flushing buffers. It requires read access to the device, often needing root privileges or membership in the input group. Output format: timestamp type code value, with legends for types like KEY_A (1 30 1) for 'A' key press.

Common use cases: testing USB devices, diagnosing touch input, or scripting event capture. Available in the evtest or input-tools package on most distributions.

CAVEATS

Requires read access to /dev/input/event*; use sudo or add user to 'input' group. Grabbing (-g) may interfere with desktop use. High event volume on busy devices can spam output. Not for production; for testing only.

DEVICE IDENTIFICATION

Use ls -l /dev/input/by-path/ or grep -A 5 -E 'Handlers|Name' /proc/bus/input/devices to find eventN for specific hardware.

EVENT TYPES

Common: EV_KEY (1)=keys, EV_REL (2)=relative motion, EV_ABS (3)=absolute (touch), EV_MSC (4)=misc. Full list via evtest --info.

HISTORY

Originally developed by Henrique de Moraes Holschuh around 2005 for evdev testing. Maintained in input-tools package; current versions (e.g., 1.34+) add query/info options and type filtering. Integrated into major distros like Ubuntu, Fedora via evtest package.

SEE ALSO

lsinput(1), evemu(1), inputattach(1)

Copied to clipboard