Haiku API Bindings
key_info
Not logged in

Documentation | InterfaceKit | key_info

DESCRIPTION

Exposes the C++ key_info struct as a native map.

FIELDS

modifiers

An integer conatining a bitmask that can be tested against the modifier key constants.

key_states

A 16-byte chunk of raw data.

Each key on the keyboard has a unique integer code that identifies it. So the A key (for example) always has the same value no matter where it is physically located on a particular keyboard. The left and right shift keys have different key codes.

Each bit in the key_states data represents a key. If the bit is 1, the key is down. If the bit is 0, the key is up. However, lock keys are set to 1 if the lock is on and 0 if the lock is off.

The bits in the data are read from left to right. The very first bit (index 0) does not represent a key. The next bit (index 1) represents the Escape key.

See https://api.haiku-os.org/keyboard.html for a mapping of the key codes to the locations on a standard US keyboard.

The Be Book also lists a few other key codes: