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

# hkbd(4)

HID keyboard driver

## NAME

**hkbd** – HID keyboard driver

## SYNOPSIS

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

**device hkbd** **device hid** **device hidbus** **device evdev** **options EVDEV\_SUPPORT**

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

```
hkbd_load="YES"
```

## DESCRIPTION

The **hkbd** driver provides support for keyboards that attach to the HID transport backend. hid(4), [hidbus(4)](/hidbus/4.md), and one of [iichid(4)](/iichid/4.md) or [usbhid(4)](/usbhid/4.md) must be configured in the kernel as well.

## CONFIGURATION

By default, the keyboard subsystem does not create the appropriate devices yet. Make sure you reconfigure your kernel with the following option in the kernel config file:

```
options KBD_INSTALL_CDEV
```

If both an AT keyboard HID keyboards are used at the same time, the AT keyboard will appear as *kbd0* in */dev*. The HID keyboards will be *kbd1*, *kbd2*, etc. You can see some information about the keyboard with the following command:

```
kbdcontrol -i < /dev/kbd1
```

or load a keymap with

```
kbdcontrol -l keymaps/pt.iso < /dev/kbd1
```

See [kbdcontrol(1)](/kbdcontrol/1.md) for more possible options.

You can swap console keyboards by using the command

```
kbdcontrol -k /dev/kbd1
```

From this point on, the first HID keyboard will be the keyboard to be used by the console.

If you want to use a HID keyboard as your default and not use an AT keyboard at all, you will have to remove the **device atkbd** line from the kernel configuration file. Because of the device initialization order, the HID keyboard will be detected *after* the console driver initializes itself and you have to explicitly tell the console driver to use the existence of the HID keyboard. This can be done in one of the following two ways.

Run the following command as a part of system initialization:

```
kbdcontrol -k /dev/kbd0 < /dev/ttyv0 > /dev/null
```

(Note that as the HID keyboard is the only keyboard, it is accessed as */dev/kbd0*) or otherwise tell the console driver to periodically look for a keyboard by setting a flag in the kernel configuration file:

```
device sc0 at isa? flags 0x100
```

With the above flag, the console driver will try to detect any keyboard in the system if it did not detect one while it was initialized at boot time.

## DRIVER CONFIGURATION

**options KBD\_INSTALL\_CDEV**

Make the keyboards available through a character device in */dev*.

**options** **HKBD\_DFLT\_KEYMAP**

**makeoptions** **HKBD\_DFLT\_KEYMAP=fr.iso**

The above lines will put the French ISO keymap in the ukbd driver. You can specify any keymap in */usr/share/syscons/keymaps* or */usr/share/vt/keymaps* (depending on the console driver being used) with this option.

**options KBD\_DISABLE\_KEYMAP\_LOADING**

Do not allow the user to change the keymap. Note that these options also affect the AT keyboard driver, [atkbd(4)](/atkbd/4.md).

## SYSCTL VARIABLES

The following variables are available as both [sysctl(8)](/sysctl/8.md) variables and [loader(8)](/loader/8.md) tunables:

- *hw.hid.hkbd.debug*

  Debug output level, where 0 is debugging disabled and larger values increase debug message verbosity. Default is 0.

- *hw.hid.hkbd.apple\_swap\_cmd\_opt*

  Swap the Command & Option keys on Apple keyboards if set to 1. Default is 0.

- *hw.hid.hkbd.apple\_swap\_cmd\_ctl*

  Swap the Command & Control keys on Apple keyboards if set to 1. Default is 0.

- *hw.hid.hkbd.apple\_fn\_mode*

  Direct access to media keys without holding Fn if set to 1. Default is 0.

- *hw.hid.hkbd.no\_leds*

  Disables setting of keyboard LEDs if set to 1. Default is 0.

## FILES

- */dev/kbd\**

  blocking device nodes

- */dev/input/event\**

  input event device nodes.

## EXAMPLES

**device hkbd**

Add the **hkbd** driver to the kernel.

## SEE ALSO

[kbdcontrol(1)](/kbdcontrol/1.md), hid(4), [hidbus(4)](/hidbus/4.md), [iichid(4)](/iichid/4.md), [syscons(4)](/syscons/4.md), [usbhid(4)](/usbhid/4.md), [vt(4)](/vt/4.md), [config(8)](/config/8.md)

## AUTHORS

The **hkbd** driver was written by Lennart Augustsson ⟨*augustss@cs.chalmers.se*⟩ for NetBSD and was substantially rewritten for FreeBSD by Kazutaka YOKOTA ⟨*yokota@zodiac.mech.utsunomiya-u.ac.jp*⟩.

This manual page was written by Nick Hibma ⟨*n\_hibma@FreeBSD.org*⟩ with a large amount of input from Kazutaka YOKOTA ⟨*yokota@zodiac.mech.utsunomiya-u.ac.jp*⟩.
