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 labelKey codeCharacter reported
Backspace0x1eB_BACKSPACE
Tab0x26B_TAB
Enter0x47B_ENTER
space bar0x5eB_SPACE
Escape0x01B_ESCAPE
F1–F12 0x02 through0x0dB_FUNCTION_KEY
Print Screen0x0eB_FUNCTION_KEY
Scroll Lock0x0fB_FUNCTION_KEY
Pause0x10B_FUNCTION_KEY
System Request0x7e0xc8
Break0x7f0xca
Insert0x1fB_INSERT
Home0x20B_HOME
Page Up0x21B_PAGE_UP
Delete0x34B_DELETE
End0x35B_END
Page Down0x36B_PAGE_DOWN
up arrow0x57B_UP_ARROW
left arrow0x61B_LEFT_ARROW
down arrow0x62B_DOWN_ARROW
right arrow0x63B_RIGHT_ARROW

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:

B_F1_KEYB_F6_KEYB_F11_KEY
B_F2_KEYB_F7_KEYB_F12_KEY
B_F3_KEYB_F8_KEYB_PRINT_KEY (the "Print Screen" key)
B_F4_KEYB_F9_KEYB_SCROLL_KEY (the "Scroll Lock" key)
B_F5_KEYB_F10_KEYB_PAUSE_KEY

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.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.