Skip to content

input_report_key()

Purpose

Reports a key or button state change to the input subsystem.

#include <linux/input.h>

Prototype

void input_report_key(struct input_dev *dev, unsigned int code, int value);

Parameters

  • dev: input device.
  • code: key code, such as KEY_ENTER.
  • value: key state. 1 means pressed, 0 means released.

Return Value

None.

Minimal Example

input_report_key(input, KEY_ENTER, 1);
input_sync(input);

input_report_key(input, KEY_ENTER, 0);
input_sync(input);

Common Pitfalls

  • Call input_sync() after reporting one logical event frame.
  • The key code should be declared through input_set_capability() before registration.