Keyboard Codes
The table below shows the IUP codification of common keys in a keyboard. Each key is represented by an integer value, defined in the "iupkey.h" file header, which should be included in the application to use the key definitions. These keys are used in K_ANY and KEYPRESS_CB callbacks to inform the key that was pressed on the keyboard.
From the definition in the table, change the prefix to K_s*, K_c*, K_m* and K_y* to add the respective modifier (Shift, Control, Alt and Sys). Sys in Windows is the Windows key and in Mac is the Apple key. Check the "iupkey.h" file header for all the definitions.
IUP provides definitions only for common control keys and ASCii characters. Other key combinations are accessed using the macros described below. Also, the global attribute "MODKEYSTATE" can be used to detect the combination of two or more modifiers. Notice that some key combinations are never available because they are restricted by the system. Notice that all of this does not affect the IupText and IupMultiline text input.
The iup_isprint(key) macro informs if a key can be directly used as a printable character. The iup_isXkey(key) macro informs if a given key is an extended code. The iup_isKeyPadXkey(key) macro informs if a given key is a numeric keypad code. The iup_isShiftXkey(key) macro informs if a given key is an extended code using the Shift modifier, the iup_isCtrlXkey(key) macro for the Ctrl modifier, the iup_isAltXkey(key) macro for the Alt modifier, and the iup_isSysXkey(key) macro for the Sys modifier. To obtain a key code for a generic combination you can start with the base key from the table and combine it repeated times using the macros iup_XkeyShift(key), iup_XkeyCtrl(key), iup_XkeyAlt(key) and iup_XkeySys(key).
| Key | Code / Callback |
|---|---|
| Space | K_SP |
| ! | K_exclam |
| " | K_quotedbl |
| # | K_numbersign |
| $ | K_dollar |
| % | K_percent |
| & | K_ampersand |
| ' | K_apostrophe |
| ( | K_parentleft |
| ) | K_parentright |
| * | K_asterisk |
| + | K_plus |
| , | K_comma |
| - | K_minus |
| . | K_period |
| / | K_slash |
| 0 | K_0 |
| 1 | K_1 |
| 2 | K_2 |
| 3 | K_3 |
| 4 | K_4 |
| 5 | K_5 |
| 6 | K_6 |
| 7 | K_7 |
| 8 | K_8 |
| 9 | K_9 |
| : | K_colon |
| ; | K_semicolon |
| < | K_less |
| = | K_equal |
| > | K_greater |
| ? | K_question |
| @ | K_at |
| A | K_A |
| B | K_B |
| C | K_C |
| D | K_D |
| E | K_E |
| F | K_F |
| G | K_G |
| H | K_H |
| I | K_I |
| J | K_J |
| K | K_K |
| L | K_L |
| M | K_M |
| N | K_N |
| O | K_O |
| P | K_P |
| Q | K_Q |
| R | K_R |
| S | K_S |
| T | K_T |
| U | K_U |
| V | K_V |
| W | K_W |
| X | K_X |
| Y | K_Y |
| Z | K_Z |
| [ | K_bracketleft |
| \ | K_backslash |
| ] | K_bracketright |
| ^ | K_circum |
| _ | K_underscore |
| ` | K_grave |
| a | K_a |
| b | K_b |
| c | K_c |
| d | K_d |
| e | K_e |
| f | K_f |
| g | K_g |
| h | K_h |
| i | K_i |
| j | K_j |
| k | K_k |
| l | K_l |
| m | K_m |
| n | K_n |
| o | K_o |
| p | K_p |
| q | K_q |
| r | K_r |
| s | K_s |
| t | K_t |
| u | K_u |
| v | K_v |
| w | K_w |
| x | K_x |
| y | K_y |
| z | K_z |
| { | K_braceleft |
| | | K_bar |
| } | K_braceright |
| ~ | K_tilde |
| Esc | K_ESC |
| Enter | K_CR |
| BackSpace | K_BS |
| Insert | K_INS |
| Del | K_DEL |
| Tab | K_TAB |
| Home | K_HOME |
| Up Arrow | K_UP |
| PgUp | K_PGUP |
| Left Arrow | K_LEFT |
| Middle | K_MIDDLE |
| Right Arrow | K_RIGHT |
| End | K_END |
| Down Arrow | K_DOWN |
| PgDn | K_PGDN |
| Pause | K_PAUSE |
| Print Screen | K_Print |
| Context Menu | K_Menu |
| ´ | K_acute |
| ç | K_ccedilla |
| ¨ | K_diaeresis |
| F1 | K_F1 |
| F2 | K_F2 |
| F3 | K_F3 |
| F4 | K_F4 |
| F5 | K_F5 |
| F6 | K_F6 |
| F7 | K_F7 |
| F8 | K_F8 |
| F9 | K_F9 |
| F10 | K_F10 |
| F11 | K_F11 |
| F12 | K_F12 |
| F13 | K_F13 |
| F14 | K_F14 |
| F15 | K_F15 |
| F16 | K_F16 |
| F17 | K_F17 |
| F18 | K_F18 |
| F19 | K_F19 |
| F20 | K_F20 |
| Clear | K_CLEAR |
| Help | K_HELP |
| Left Shift | K_LSHIFT |
| Right Shift | K_RSHIFT |
| Left Ctrl | K_LCTRL |
| Right Ctrl | K_RCTRL |
| Left Alt | K_LALT |
| Right Alt | K_RALT |
| Scroll Lock | K_SCROLL |
| Num Lock | K_NUM |
| Caps Lock | K_CAPS |
K_CLEAR is reported in Win32, WinUI and macOS. K_HELP is reported in macOS, iOS, Qt and FLTK.
The numeric keypad has its own codes, so its keys can be distinguished from the main keyboard. When Num Lock is off the navigation codes are reported, when it is on the digit codes are reported. Keypad F1 to F4, Keypad Space and Keypad Tab are reported as K_F1 to K_F4, K_SP and K_TAB. TEXTINPUT_CB is not called for the keypad keys, they are reported only in K_ANY and KEYPRESS_CB. In macOS and iOS the keypad has no navigation keys.
| Key | Code / Callback |
|---|---|
| Keypad Enter | K_KP_CR |
| Keypad Home | K_KP_HOME |
| Keypad Left Arrow | K_KP_LEFT |
| Keypad Up Arrow | K_KP_UP |
| Keypad Right Arrow | K_KP_RIGHT |
| Keypad Down Arrow | K_KP_DOWN |
| Keypad PgUp | K_KP_PGUP |
| Keypad PgDn | K_KP_PGDN |
| Keypad End | K_KP_END |
| Keypad Middle | K_KP_MIDDLE |
| Keypad Insert | K_KP_INS |
| Keypad Del | K_KP_DEL |
| Keypad * | K_KP_MULT |
| Keypad + | K_KP_PLUS |
| Keypad , | K_KP_SEP |
| Keypad - | K_KP_MINUS |
| Keypad . | K_KP_DECIMAL |
| Keypad / | K_KP_DIV |
| Keypad 0 | K_KP_0 |
| Keypad 1 | K_KP_1 |
| Keypad 2 | K_KP_2 |
| Keypad 3 | K_KP_3 |
| Keypad 4 | K_KP_4 |
| Keypad 5 | K_KP_5 |
| Keypad 6 | K_KP_6 |
| Keypad 7 | K_KP_7 |
| Keypad 8 | K_KP_8 |
| Keypad 9 | K_KP_9 |
| Keypad = | K_KP_EQUAL |