]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/keys.sgml
=== Released 2.3.3 ===
[~andy/gtk] / docs / reference / gdk / tmpl / keys.sgml
1 <!-- ##### SECTION Title ##### -->
2 Key Values
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Functions for manipulating keyboard codes
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
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>&lt;gdk/gdkkeysyms.h&gt;</filename>
14 header file. <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> is not included in <filename>&lt;gtk/gtk.h&gt;</filename>, 
15 it must be included independently, because the file is quite large.
16 </para>
17 <para>
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().
21 </para>
22 <para>
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().
26 </para>
27 <para>
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().
30 </para>
31
32 <para>
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.
53 </para>
54
55 <para>
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
66 keyboard state.
67 </para>
68
69 <para>
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.
75
76 </para>
77
78 <!-- ##### SECTION See_Also ##### -->
79 <para>
80
81 </para>
82
83 <!-- ##### STRUCT GdkKeymap ##### -->
84 <para>
85 A <structname>GdkKeymap</structname> defines the translation from keyboard state
86 (including a hardware key, a modifier mask, and active keyboard group)
87 to a keyval. This translation has two phases. The first phase is
88 to determine the effective keyboard group and level for the keyboard
89 state; the second phase is to look up the keycode/group/level triplet
90 in the keymap and see what keyval it corresponds to.
91 </para>
92
93
94 <!-- ##### SIGNAL GdkKeymap::direction-changed ##### -->
95 <para>
96
97 </para>
98
99 @keymap: the object which received the signal.
100
101 <!-- ##### SIGNAL GdkKeymap::keys-changed ##### -->
102 <para>
103
104 </para>
105
106 @keymap: the object which received the signal.
107
108 <!-- ##### STRUCT GdkKeymapKey ##### -->
109 <para>
110 A <structname>GdkKeymapKey</structname> is a hardware key that can 
111 be mapped to a keyval.
112 </para>
113
114 @keycode: the hardware keycode. This is an identifying number for a 
115   physical key.
116 @group: indicates movement in a horizontal direction. Usually groups are used 
117   for two different languages. In group 0, a key might have two English 
118   characters, and in group 1 it might have two Hebrew characters. The Hebrew 
119   characters will be printed on the key next to the English characters.
120 @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 
121   exclamation point ("!") character on it. The level indicates whether to use 
122   the "1" or the "!" symbol. The letter keys are considered to have a lowercase
123   letter at level 0, and an uppercase letter at level 1, though only the 
124   uppercase letter is printed.
125
126 <!-- ##### FUNCTION gdk_keymap_get_default ##### -->
127 <para>
128
129 </para>
130
131 @Returns: 
132
133
134 <!-- ##### FUNCTION gdk_keymap_get_for_display ##### -->
135 <para>
136
137 </para>
138
139 @display: 
140 @Returns: 
141
142
143 <!-- ##### FUNCTION gdk_keymap_lookup_key ##### -->
144 <para>
145
146 </para>
147
148 @keymap: 
149 @key: 
150 @Returns: 
151
152
153 <!-- ##### FUNCTION gdk_keymap_translate_keyboard_state ##### -->
154 <para>
155
156 </para>
157
158 @keymap: 
159 @hardware_keycode: 
160 @state: 
161 @group: 
162 @keyval: 
163 @effective_group: 
164 @level: 
165 @consumed_modifiers: 
166 @Returns: 
167 <!-- # Unused Parameters # -->
168 @unused_modifiers: 
169
170
171 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
172 <para>
173
174 </para>
175
176 @keymap: 
177 @keyval: 
178 @keys: 
179 @n_keys: 
180 @Returns: 
181
182
183 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keycode ##### -->
184 <para>
185
186 </para>
187
188 @keymap: 
189 @hardware_keycode: 
190 @keys: 
191 @keyvals: 
192 @n_entries: 
193 @Returns: 
194
195
196 <!-- ##### FUNCTION gdk_keymap_get_direction ##### -->
197 <para>
198 Returns the direction of the keymap. 
199 </para>
200
201 @keymap: a #GdkKeymap or %NULL to use the default keymap.
202 Returns: %PANGO_DIRECTION_LTR or %PANGO_DIRECTION_RTL.
203 @Returns: the direction of the keymap.
204
205
206 <!-- ##### FUNCTION gdk_keyval_name ##### -->
207 <para>
208 Converts a key value into a symbolic name.
209 The names are the same as those in the <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
210 but without the leading "GDK_".
211 </para>
212
213 @keyval: a key value.
214 @Returns: a string containing the name of the key, or %NULL if @keyval is not
215 a valid key. The string should not be modified.
216
217
218 <!-- ##### FUNCTION gdk_keyval_from_name ##### -->
219 <para>
220 Converts a key name to a key value.
221 </para>
222
223 @keyval_name: a key name.
224 @Returns: the corresponding key value, or %GDK_VoidSymbol if the key name is
225 not a valid key.
226
227
228 <!-- ##### FUNCTION gdk_keyval_convert_case ##### -->
229 <para>
230
231 </para>
232
233 @symbol: 
234 @lower: 
235 @upper: 
236
237
238 <!-- ##### FUNCTION gdk_keyval_to_upper ##### -->
239 <para>
240 Converts a key value to upper case, if applicable.
241 </para>
242
243 @keyval: a key value.
244 @Returns: the upper case form of @keyval, or @keyval itself if it is already
245 in upper case or it is not subject to case conversion.
246
247
248 <!-- ##### FUNCTION gdk_keyval_to_lower ##### -->
249 <para>
250 Converts a key value to lower case, if applicable.
251 </para>
252
253 @keyval: a key value.
254 @Returns: the lower case form of @keyval, or @keyval itself if it is already
255 in lower case or it is not subject to case conversion.
256
257
258 <!-- ##### FUNCTION gdk_keyval_is_upper ##### -->
259 <para>
260 Returns %TRUE if the given key value is in upper case.
261 </para>
262
263 @keyval: a key value.
264 @Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
265 case conversion.
266
267
268 <!-- ##### FUNCTION gdk_keyval_is_lower ##### -->
269 <para>
270 Returns %TRUE if the given key value is in lower case.
271 </para>
272
273 @keyval: a key value.
274 @Returns: %TRUE if @keyval is in lower case, or if @keyval is not subject to
275 case conversion.
276
277
278 <!-- ##### FUNCTION gdk_keyval_to_unicode ##### -->
279 <para>
280
281 </para>
282
283 @keyval: 
284 @Returns: 
285
286
287 <!-- ##### FUNCTION gdk_unicode_to_keyval ##### -->
288 <para>
289
290 </para>
291
292 @wc: 
293 @Returns: 
294
295