Keyboard Messages


B_KEY_DOWN, B_KEY_UP, B_UNMAPPED_KEY_DOWN, B_UNMAPPED_KEY_UP

Source:The system.
Target:The focus view's BWindow.
Hook:BView::KeyDown() (B_KEY_DOWN)
BView::KeyUp() (B_KEY_UP)
(The …UNMAPPED… messages don't map to hook functions.)

B_KEY_DOWN is sent when the user presses (or holds down) a key that's mapped to a character; B_KEY_UP is sent when the user releases the key. B_UNMAPPED_KEY_DOWN and B_UNMAPPED_KEY_UP are sent if the key isn't mapped to a character. This doesn't include modifier keys, which are reported in the B_MODIFIERS_CHANGED message.

FieldType codeDescription
whenB_INT64_TYPEEvent time, in microseconds since 01/01/70
keyB_INT32_TYPEThe code for the physical key that was pressed. See "More On Keyboard Mapping" for a discussion of the keymap.
be:key_repeatB_INT32_TYPEThe "iteration number" of this key down. When the user holds the key down, successive messages are sent with increasing key repeat values. This field isn't present in the initial event; the first repeat message (i.e., the second key down message) has a key repeat value of 1. (B_KEY_DOWN only)
modifiersB_INT32_TYPEThe modifier keys that were in effect at the time of the event. See "Modifier Keys" for a list of values.
statesB_UINT8_TYPEThe state of all keys at the time of the event. See "Key States."
byte[3]B_INT8_TYPEThe UTF-8 data that's generated. (B_KEY_DOWN and B_KEY_UP only)
bytesB_STRING_TYPEThe string that's generated. (The string usually contains a single character.) (B_KEY_DOWN and B_KEY_UP only)
raw_charB_INT32_TYPEModifier-independent ASCII code for the character. (B_KEY_DOWN and B_KEY_UP only)
Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.