---
name: "gpiokeys"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd", "openbsd"]
url: "https://new.carta.tech/gpiokeys"
---

# gpiokeys(4)

GPIO keys device driver

## NAME

**gpiokeys** – GPIO keys device driver

## SYNOPSIS

To compile this driver into the kernel, place the following lines in your kernel configuration file:

**options FDT** **device gpio** **device gpiokeys**

Alternatively, to load the driver as a module at boot time, place the following line in [loader.conf(5)](/loader.conf/5.md):

```
gpiokeys_load="YES"
```

## DESCRIPTION

The **gpiokeys** driver provides a way to represent a set of general purpose inputs as a [keyboard(4)](/keyboard/4.md) device. At the moment the driver supports only [FDT(4)](/FDT/4.md) based systems. The DTS determines what pins are mapped to buttons and what key codes are generated for each virtual button. The [keyboard(4)](/keyboard/4.md) device can be used from userland to monitor for input changes.

On an [FDT(4)](/FDT/4.md) based system the DTS part for a **gpiokeys** device usually looks like:

```
/ {
	...
	gpio_keys {
		compatible = "gpio-keys";
		btn1 {
			label = "button1";
			linux,code = <KEY_1>;
			gpios = <&gpio 0 3 GPIO_ACTIVE_LOW>
		};
		btn2 {
			label = "button2";
			linux,code = <KEY_2>;
			gpios = <&gpio 0 4 GPIO_ACTIVE_LOW>
		};
	};
};
```

For more details about the *gpios* property, please consult */usr/src/sys/dts/bindings-gpio.txt*.

The **gpiokeys** driver supports two properties for specifying a key code.

The property *freebsd,code* specifies a FreeBSD native scancode compatible with [kbdmap(5)](/kbdmap/5.md) keyboard maps.

The property *linux,code* specifies an evdev scancode. That scancode is internally translated to a native scancode. Note that not all evdev scancodes have corresponding native scancodes. If a scancode cannot be translated, then a diagnostic message is printed and the input is ignored.

The property *label* is a descriptive name of a button. It is used for diagnostic messages only. This property is optional. If not set, the node name is used in its place.

The property *autorepeat* determines whether autorepeat is enabled for a button.

The property *debounce-interval* defines debouncing interval time in milliseconds. If not specified the interval defaults to 5.

## SEE ALSO

[fdt(4)](/fdt/4.md), [gpio(4)](/gpio/4.md), [keyboard(4)](/keyboard/4.md), [kbdmap(5)](/kbdmap/5.md)

## HISTORY

The **gpiokeys** manual page first appeared in FreeBSD 12.2.

## AUTHORS

The **gpiokeys** driver was written by Oleksandr Tymoshenko ⟨*gonzo@FreeBSD.org*⟩. This manual page was written by Andriy Gapon ⟨*avg@FreeBSD.org*⟩.
