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><gtk/gtk.h></filename>,
15 it must be included independently, because the file is quite large.
18 Key values can be converted into a string representation using
19 gdk_keyval_name(). The reverse function, converting a string to a key value,
20 is provided by gdk_keyval_from_name().
23 The case of key values can be determined using gdk_keyval_is_upper() and
24 gdk_keyval_is_lower(). Key values can be converted to upper or lower case
25 using gdk_keyval_to_upper() and gdk_keyval_to_lower().
28 When it makes sense, key values can be converted to and from
29 Unicode characters with gdk_keyval_to_unicode() and gdk_unicode_to_keyval().
33 One #GdkKeymap object exists for each user display. gdk_keymap_get_default()
34 returns the #GdkKeymap for the default display; to obtain keymaps for other
35 displays, use gdk_keymap_get_for_display(). A keymap
36 is a mapping from #GdkKeymapKey to key values. You can think of a #GdkKeymapKey
37 as a representation of a symbol printed on a physical keyboard key. That is, it
38 contains three pieces of information. First, it contains the hardware keycode;
39 this is an identifying number for a physical key. Second, it contains the
40 <firstterm>level</firstterm> of the key. The level indicates which symbol on the
41 key will be used, in a vertical direction. So on a standard US keyboard, the key
42 with the number "1" on it also has the exclamation point ("!") character on
43 it. The level indicates whether to use the "1" or the "!" symbol. The letter
44 keys are considered to have a lowercase letter at level 0, and an uppercase
45 letter at level 1, though only the uppercase letter is printed. Third, the
46 #GdkKeymapKey contains a group; groups are not used on standard US keyboards,
47 but are used in many other countries. On a keyboard with groups, there can be 3
48 or 4 symbols printed on a single key. The group indicates movement in a
49 horizontal direction. Usually groups are used for two different languages. In
50 group 0, a key might have two English characters, and in group 1 it might have
51 two Hebrew characters. The Hebrew characters will be printed on the key next to
52 the English characters.
56 In order to use a keymap to interpret a key event, it's necessary to first
57 convert the keyboard state into an effective group and level. This is done via a
58 set of rules that varies widely according to type of keyboard and user
59 configuration. The function gdk_keymap_translate_keyboard_state() accepts a
60 keyboard state -- consisting of hardware keycode pressed, active modifiers, and
61 active group -- applies the appropriate rules, and returns the group/level to be
62 used to index the keymap, along with the modifiers which did not affect the
63 group and level. i.e. it returns "unconsumed modifiers." The keyboard group may
64 differ from the effective group used for keymap lookups because some keys don't
65 have multiple groups - e.g. the Enter key is always in group 0 regardless of
70 Note that gdk_keymap_translate_keyboard_state() also returns the keyval, i.e. it
71 goes ahead and performs the keymap lookup in addition to telling you which
72 effective group/level values were used for the lookup. #GdkEventKey already
73 contains this keyval, however, so you don't normally need to call
74 gdk_keymap_translate_keyboard_state() just to get the keyval.
78 <!-- ##### SECTION See_Also ##### -->
83 <!-- ##### SECTION Stability_Level ##### -->
86 <!-- ##### STRUCT GdkKeymap ##### -->
88 A <structname>GdkKeymap</structname> defines the translation from keyboard state
89 (including a hardware key, a modifier mask, and active keyboard group)
90 to a keyval. This translation has two phases. The first phase is
91 to determine the effective keyboard group and level for the keyboard
92 state; the second phase is to look up the keycode/group/level triplet
93 in the keymap and see what keyval it corresponds to.
97 <!-- ##### SIGNAL GdkKeymap::direction-changed ##### -->
102 @keymap: the object which received the signal.
104 <!-- ##### SIGNAL GdkKeymap::keys-changed ##### -->
109 @keymap: the object which received the signal.
111 <!-- ##### STRUCT GdkKeymapKey ##### -->
113 A <structname>GdkKeymapKey</structname> is a hardware key that can
114 be mapped to a keyval.
117 @keycode: the hardware keycode. This is an identifying number for a
119 @group: indicates movement in a horizontal direction. Usually groups are used
120 for two different languages. In group 0, a key might have two English
121 characters, and in group 1 it might have two Hebrew characters. The Hebrew
122 characters will be printed on the key next to the English characters.
123 @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
124 exclamation point ("!") character on it. The level indicates whether to use
125 the "1" or the "!" symbol. The letter keys are considered to have a lowercase
126 letter at level 0, and an uppercase letter at level 1, though only the
127 uppercase letter is printed.
129 <!-- ##### FUNCTION gdk_keymap_get_default ##### -->
137 <!-- ##### FUNCTION gdk_keymap_get_for_display ##### -->
146 <!-- ##### FUNCTION gdk_keymap_lookup_key ##### -->
156 <!-- ##### FUNCTION gdk_keymap_translate_keyboard_state ##### -->
172 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
184 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keycode ##### -->
197 <!-- ##### FUNCTION gdk_keymap_get_direction ##### -->
199 Returns the direction of the keymap.
202 @keymap: a #GdkKeymap or %NULL to use the default keymap.
203 Returns: %PANGO_DIRECTION_LTR or %PANGO_DIRECTION_RTL.
204 @Returns: the direction of the keymap.
207 <!-- ##### FUNCTION gdk_keyval_name ##### -->
209 Converts a key value into a symbolic name.
210 The names are the same as those in the <filename><gdk/gdkkeysyms.h></filename> header file
211 but without the leading "GDK_".
214 @keyval: a key value.
215 @Returns: a string containing the name of the key, or %NULL if @keyval is not
216 a valid key. The string should not be modified.
219 <!-- ##### FUNCTION gdk_keyval_from_name ##### -->
221 Converts a key name to a key value.
224 @keyval_name: a key name.
225 @Returns: the corresponding key value, or %GDK_VoidSymbol if the key name is
229 <!-- ##### FUNCTION gdk_keyval_convert_case ##### -->
239 <!-- ##### FUNCTION gdk_keyval_to_upper ##### -->
241 Converts a key value to upper case, if applicable.
244 @keyval: a key value.
245 @Returns: the upper case form of @keyval, or @keyval itself if it is already
246 in upper case or it is not subject to case conversion.
249 <!-- ##### FUNCTION gdk_keyval_to_lower ##### -->
251 Converts a key value to lower case, if applicable.
254 @keyval: a key value.
255 @Returns: the lower case form of @keyval, or @keyval itself if it is already
256 in lower case or it is not subject to case conversion.
259 <!-- ##### FUNCTION gdk_keyval_is_upper ##### -->
261 Returns %TRUE if the given key value is in upper case.
264 @keyval: a key value.
265 @Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
269 <!-- ##### FUNCTION gdk_keyval_is_lower ##### -->
271 Returns %TRUE if the given key value is in lower case.
274 @keyval: a key value.
275 @Returns: %TRUE if @keyval is in lower case, or if @keyval is not subject to
279 <!-- ##### FUNCTION gdk_keyval_to_unicode ##### -->
288 <!-- ##### FUNCTION gdk_unicode_to_keyval ##### -->