Character Constants¶
The Interface Kit defines constants for characters that aren’t normally represented by a visible symbol. This includes the usual space and backspace characters, but most invisible characters are produced by the function keys and the navigation keys located between the main keyboard and the numeric keypad. The character values associated with these keys are more or less arbitrary, so you should always use the constant in your code rather than the actual character value. Many of these characters are also produced by alphabetic keys when a Control key is held down.
The table below lists character constants defined in the kit and the keys they’re associated with.
Key label |
Key code |
Character reported |
---|---|---|
Backspace |
0x1e |
|
Tab |
0x26 |
|
Enter |
0x47 |
|
space bar |
0x5e |
|
Escape |
0x01 |
|
F1–F12 0x02 through |
0x0d |
|
Print Screen |
0x0e |
|
Scroll Lock |
0x0f |
|
Pause |
0x10 |
|
System Request |
0x7e |
0xc8 |
Break |
0x7f |
0xca |
Insert |
0x1f |
|
Home |
0x20 |
|
Page Up |
0x21 |
|
Delete |
0x34 |
|
End |
0x35 |
|
Page Down |
0x36 |
|
up arrow |
0x57 |
|
left arrow |
0x61 |
|
down arrow |
0x62 |
|
right arrow |
0x63 |
|
Several keys are mapped to the B_FUNCTION_KEY
character.
An application can determine which function key was pressed to produce the
character by testing the key code against these constants:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Note that key 0x30 P is also mapped to
B_FUNCTION_KEY
when the Control key is held down.
Each of the character constants listed above is a one-byte value falling in the range of values where ASCII and Unicode™ overlap. For convenience, the Interface Kit also defines some constants for common characters that fall outside that range. These characters have multibyte representations in UTF-8, so the constant is defined as a character string. For example:
#define B_UTF8_OPEN_QUOTE "xE2x80x9C"
#define B_UTF8_CLOSE_QUOTE "xE2x80x9D"
#define B_UTF8_COPYRIGHT "xC2xA9"
See “Character Constants
” in the
“General Constants” section of The Interface Kit for a full list of
these constants.