The Be Book Keyboard Keyboard Index

More on Keyboard Mapping

The key map records character values using the UTF-8 encoding of the Unicode Standard, making it possible to map keys to characters in any of the world's scripts. UTF-8 encodes 16-bit Unicode values in a variable number of bytes (from one to four). The main benefit to UTF-8 is that one-byte UTF characters $00 through $7F are identical to the ASCII standard that's been around for decades.

A B_KEY_DOWN message holds the character mapped to the key the user pressed as an array of bytes named, simply, "byte". The array is passed as a string to the KeyDown() hook function along with a count of the number of bytes in the string:

virtual void KeyDown(const char *bytes, int32 numBytes)

See "Character Encoding" in the "Responding to the User" section of the Interface Kit for a description of UTF-8 encoding and get_key_map() for an explanation of the key map.

Most keys are mapped to more than one character. The precise character that the key produces depends on which modifier keys are being held down and which lock states the keyboard is in at the time the key is pressed.

A few examples are given in the table below:

Key No modifiers Shift alone Option alone Shift + Option Control
0x15 4 $ 4
0x18 7 & xa6 xa4 7
0x26 B_TAB B_TAB B_TAB B_TAB B_TAB
0x2e i I B_TAB
0x40 g G " 0x07
0x43 k K B_PAGE_UP
0x51 n N ñ Ñ 0x0e
0x55 / ? xb8 xc0 /
0x64 B_INSERT 0 B_INSERT 0 B_INSERT

The mapping follows some fixed rules, including these:

The default key map also follows the conventional rules for Caps Lock and Control:


The Be Book Keyboard Keyboard Index

The Be Book,
...in lovely HTML...
for BeOS Release 5.

Copyright © 2000 Be, Inc. All rights reserved..