]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/keys.sgml
Keysyms docs update
[~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;gdk/gdk.h&gt;</filename>, 
15 it must be included independently, because the file is quite large.
16 </para>
17 <para>
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).
21 </para>
22 <para>
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().
26 </para>
27 <para>
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().
31 </para>
32 <para>
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().
35 </para>
36
37 <para>
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.
58 </para>
59
60 <para>
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
71 keyboard state.
72 </para>
73
74 <para>
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.
80
81 </para>
82
83 <!-- ##### SECTION See_Also ##### -->
84 <para>
85
86 </para>
87
88 <!-- ##### SECTION Stability_Level ##### -->
89
90
91 <!-- ##### STRUCT GdkKeymap ##### -->
92 <para>
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.
99 </para>
100
101
102 <!-- ##### SIGNAL GdkKeymap::direction-changed ##### -->
103 <para>
104
105 </para>
106
107 @keymap: the object which received the signal.
108
109 <!-- ##### SIGNAL GdkKeymap::keys-changed ##### -->
110 <para>
111
112 </para>
113
114 @keymap: the object which received the signal.
115
116 <!-- ##### SIGNAL GdkKeymap::state-changed ##### -->
117 <para>
118
119 </para>
120
121 @gdkkeymap: the object which received the signal.
122
123 <!-- ##### STRUCT GdkKeymapKey ##### -->
124 <para>
125 A <structname>GdkKeymapKey</structname> is a hardware key that can 
126 be mapped to a keyval.
127 </para>
128
129 @keycode: the hardware keycode. This is an identifying number for a 
130   physical key.
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.
140
141 <!-- ##### FUNCTION gdk_keymap_get_default ##### -->
142 <para>
143
144 </para>
145
146 @Returns: 
147
148
149 <!-- ##### FUNCTION gdk_keymap_get_for_display ##### -->
150 <para>
151
152 </para>
153
154 @display: 
155 @Returns: 
156
157
158 <!-- ##### FUNCTION gdk_keymap_lookup_key ##### -->
159 <para>
160
161 </para>
162
163 @keymap: 
164 @key: 
165 @Returns: 
166
167
168 <!-- ##### FUNCTION gdk_keymap_translate_keyboard_state ##### -->
169 <para>
170
171 </para>
172
173 @keymap: 
174 @hardware_keycode: 
175 @state: 
176 @group: 
177 @keyval: 
178 @effective_group: 
179 @level: 
180 @consumed_modifiers: 
181 @Returns: 
182
183
184 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
185 <para>
186
187 </para>
188
189 @keymap: 
190 @keyval: 
191 @keys: 
192 @n_keys: 
193 @Returns: 
194
195
196 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keycode ##### -->
197 <para>
198
199 </para>
200
201 @keymap: 
202 @hardware_keycode: 
203 @keys: 
204 @keyvals: 
205 @n_entries: 
206 @Returns: 
207
208
209 <!-- ##### FUNCTION gdk_keymap_get_direction ##### -->
210 <para>
211 Returns the direction of the keymap. 
212 </para>
213
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.
217
218
219 <!-- ##### FUNCTION gdk_keymap_have_bidi_layouts ##### -->
220 <para>
221
222 </para>
223
224 @keymap: 
225 @Returns: 
226
227
228 <!-- ##### FUNCTION gdk_keymap_get_caps_lock_state ##### -->
229 <para>
230
231 </para>
232
233 @keymap: 
234 @Returns: 
235
236
237 <!-- ##### FUNCTION gdk_keyval_name ##### -->
238 <para>
239 Converts a key value into a symbolic name.
240 The names are the same as those in the <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
241 but without the leading "GDK_".
242 </para>
243
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.
247
248
249 <!-- ##### FUNCTION gdk_keyval_from_name ##### -->
250 <para>
251 Converts a key name to a key value.
252 </para>
253
254 @keyval_name: a key name.
255 @Returns: the corresponding key value, or %GDK_VoidSymbol if the key name is
256 not a valid key.
257
258
259 <!-- ##### FUNCTION gdk_keyval_convert_case ##### -->
260 <para>
261
262 </para>
263
264 @symbol: 
265 @lower: 
266 @upper: 
267
268
269 <!-- ##### FUNCTION gdk_keyval_to_upper ##### -->
270 <para>
271 Converts a key value to upper case, if applicable.
272 </para>
273
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.
277
278
279 <!-- ##### FUNCTION gdk_keyval_to_lower ##### -->
280 <para>
281 Converts a key value to lower case, if applicable.
282 </para>
283
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.
287
288
289 <!-- ##### FUNCTION gdk_keyval_is_upper ##### -->
290 <para>
291 Returns %TRUE if the given key value is in upper case.
292 </para>
293
294 @keyval: a key value.
295 @Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
296 case conversion.
297
298
299 <!-- ##### FUNCTION gdk_keyval_is_lower ##### -->
300 <para>
301 Returns %TRUE if the given key value is in lower case.
302 </para>
303
304 @keyval: a key value.
305 @Returns: %TRUE if @keyval is in lower case, or if @keyval is not subject to
306 case conversion.
307
308
309 <!-- ##### FUNCTION gdk_keyval_to_unicode ##### -->
310 <para>
311
312 </para>
313
314 @keyval: 
315 @Returns: 
316
317
318 <!-- ##### FUNCTION gdk_unicode_to_keyval ##### -->
319 <para>
320
321 </para>
322
323 @wc: 
324 @Returns: 
325
326