1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Functions for manipulating keyboard codes
7 <!-- ##### SECTION Long_Description ##### -->
9 Key values are the codes which are sent whenever a key is pressed or released.
10 They appear in the <structfield>keyval</structfield> field of the
11 #GdkEventKey structure, which is passed to signal handlers for the
12 "key-press-event" and "key-release-event" signals.
13 The complete list of key values can be found in the <filename><gdk/gdkkeysyms.h></filename>
14 header file. <filename><gdk/gdkkeysyms.h></filename> is not included in <filename><gdk/gdk.h></filename>,
15 it must be included independently, because the file is quite large.
18 Key values are regularly updated from the upstream X.org X11 implementation,
19 so new values are added regularly. They will be prefixed with GDK_ rather than
20 XF86XK_ or XK_ (for older symbols).
23 Key values can be converted into a string representation using
24 gdk_keyval_name(). The reverse function, converting a string to a key value,
25 is provided by gdk_keyval_from_name().
28 The case of key values can be determined using gdk_keyval_is_upper() and
29 gdk_keyval_is_lower(). Key values can be converted to upper or lower case
30 using gdk_keyval_to_upper() and gdk_keyval_to_lower().
33 When it makes sense, key values can be converted to and from
34 Unicode characters with gdk_keyval_to_unicode() and gdk_unicode_to_keyval().
38 One #GdkKeymap object exists for each user display. gdk_keymap_get_default()
39 returns the #GdkKeymap for the default display; to obtain keymaps for other
40 displays, use gdk_keymap_get_for_display(). A keymap
41 is a mapping from #GdkKeymapKey to key values. You can think of a #GdkKeymapKey
42 as a representation of a symbol printed on a physical keyboard key. That is, it
43 contains three pieces of information. First, it contains the hardware keycode;
44 this is an identifying number for a physical key. Second, it contains the
45 <firstterm>level</firstterm> of the key. The level indicates which symbol on the
46 key will be used, in a vertical direction. So on a standard US keyboard, the key
47 with the number "1" on it also has the exclamation point ("!") character on
48 it. The level indicates whether to use the "1" or the "!" symbol. The letter
49 keys are considered to have a lowercase letter at level 0, and an uppercase
50 letter at level 1, though only the uppercase letter is printed. Third, the
51 #GdkKeymapKey contains a group; groups are not used on standard US keyboards,
52 but are used in many other countries. On a keyboard with groups, there can be 3
53 or 4 symbols printed on a single key. The group indicates movement in a
54 horizontal direction. Usually groups are used for two different languages. In
55 group 0, a key might have two English characters, and in group 1 it might have
56 two Hebrew characters. The Hebrew characters will be printed on the key next to
57 the English characters.
61 In order to use a keymap to interpret a key event, it's necessary to first
62 convert the keyboard state into an effective group and level. This is done via a
63 set of rules that varies widely according to type of keyboard and user
64 configuration. The function gdk_keymap_translate_keyboard_state() accepts a
65 keyboard state -- consisting of hardware keycode pressed, active modifiers, and
66 active group -- applies the appropriate rules, and returns the group/level to be
67 used to index the keymap, along with the modifiers which did not affect the
68 group and level. i.e. it returns "unconsumed modifiers." The keyboard group may
69 differ from the effective group used for keymap lookups because some keys don't
70 have multiple groups - e.g. the Enter key is always in group 0 regardless of
75 Note that gdk_keymap_translate_keyboard_state() also returns the keyval, i.e. it
76 goes ahead and performs the keymap lookup in addition to telling you which
77 effective group/level values were used for the lookup. #GdkEventKey already
78 contains this keyval, however, so you don't normally need to call
79 gdk_keymap_translate_keyboard_state() just to get the keyval.
83 <!-- ##### SECTION See_Also ##### -->
88 <!-- ##### SECTION Stability_Level ##### -->
91 <!-- ##### STRUCT GdkKeymap ##### -->
93 A <structname>GdkKeymap</structname> defines the translation from keyboard state
94 (including a hardware key, a modifier mask, and active keyboard group)
95 to a keyval. This translation has two phases. The first phase is
96 to determine the effective keyboard group and level for the keyboard
97 state; the second phase is to look up the keycode/group/level triplet
98 in the keymap and see what keyval it corresponds to.
102 <!-- ##### SIGNAL GdkKeymap::direction-changed ##### -->
107 @keymap: the object which received the signal.
109 <!-- ##### SIGNAL GdkKeymap::keys-changed ##### -->
114 @keymap: the object which received the signal.
116 <!-- ##### SIGNAL GdkKeymap::state-changed ##### -->
121 @gdkkeymap: the object which received the signal.
123 <!-- ##### STRUCT GdkKeymapKey ##### -->
125 A <structname>GdkKeymapKey</structname> is a hardware key that can
126 be mapped to a keyval.
129 @keycode: the hardware keycode. This is an identifying number for a
131 @group: indicates movement in a horizontal direction. Usually groups are used
132 for two different languages. In group 0, a key might have two English
133 characters, and in group 1 it might have two Hebrew characters. The Hebrew
134 characters will be printed on the key next to the English characters.
135 @level: indicates which symbol on the key will be used, in a vertical direction. So on a standard US keyboard, the key with the number "1" on it also has the
136 exclamation point ("!") character on it. The level indicates whether to use
137 the "1" or the "!" symbol. The letter keys are considered to have a lowercase
138 letter at level 0, and an uppercase letter at level 1, though only the
139 uppercase letter is printed.
141 <!-- ##### FUNCTION gdk_keymap_get_default ##### -->
149 <!-- ##### FUNCTION gdk_keymap_get_for_display ##### -->
158 <!-- ##### FUNCTION gdk_keymap_lookup_key ##### -->
168 <!-- ##### FUNCTION gdk_keymap_translate_keyboard_state ##### -->
184 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
196 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keycode ##### -->
209 <!-- ##### FUNCTION gdk_keymap_get_direction ##### -->
211 Returns the direction of the keymap.
214 @keymap: a #GdkKeymap or %NULL to use the default keymap.
215 Returns: %PANGO_DIRECTION_LTR or %PANGO_DIRECTION_RTL.
216 @Returns: the direction of the keymap.
219 <!-- ##### FUNCTION gdk_keymap_have_bidi_layouts ##### -->
228 <!-- ##### FUNCTION gdk_keymap_get_caps_lock_state ##### -->
237 <!-- ##### FUNCTION gdk_keyval_name ##### -->
239 Converts a key value into a symbolic name.
240 The names are the same as those in the <filename><gdk/gdkkeysyms.h></filename> header file
241 but without the leading "GDK_".
244 @keyval: a key value.
245 @Returns: a string containing the name of the key, or %NULL if @keyval is not
246 a valid key. The string should not be modified.
249 <!-- ##### FUNCTION gdk_keyval_from_name ##### -->
251 Converts a key name to a key value.
254 @keyval_name: a key name.
255 @Returns: the corresponding key value, or %GDK_VoidSymbol if the key name is
259 <!-- ##### FUNCTION gdk_keyval_convert_case ##### -->
269 <!-- ##### FUNCTION gdk_keyval_to_upper ##### -->
271 Converts a key value to upper case, if applicable.
274 @keyval: a key value.
275 @Returns: the upper case form of @keyval, or @keyval itself if it is already
276 in upper case or it is not subject to case conversion.
279 <!-- ##### FUNCTION gdk_keyval_to_lower ##### -->
281 Converts a key value to lower case, if applicable.
284 @keyval: a key value.
285 @Returns: the lower case form of @keyval, or @keyval itself if it is already
286 in lower case or it is not subject to case conversion.
289 <!-- ##### FUNCTION gdk_keyval_is_upper ##### -->
291 Returns %TRUE if the given key value is in upper case.
294 @keyval: a key value.
295 @Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
299 <!-- ##### FUNCTION gdk_keyval_is_lower ##### -->
301 Returns %TRUE if the given key value is in lower case.
304 @keyval: a key value.
305 @Returns: %TRUE if @keyval is in lower case, or if @keyval is not subject to
309 <!-- ##### FUNCTION gdk_keyval_to_unicode ##### -->
318 <!-- ##### FUNCTION gdk_unicode_to_keyval ##### -->