]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/keys.sgml
2.9.0
[~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 <!-- ##### SECTION Stability_Level ##### -->
84
85
86 <!-- ##### STRUCT GdkKeymap ##### -->
87 <para>
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.
94 </para>
95
96
97 <!-- ##### SIGNAL GdkKeymap::direction-changed ##### -->
98 <para>
99
100 </para>
101
102 @keymap: the object which received the signal.
103
104 <!-- ##### SIGNAL GdkKeymap::keys-changed ##### -->
105 <para>
106
107 </para>
108
109 @keymap: the object which received the signal.
110
111 <!-- ##### STRUCT GdkKeymapKey ##### -->
112 <para>
113 A <structname>GdkKeymapKey</structname> is a hardware key that can 
114 be mapped to a keyval.
115 </para>
116
117 @keycode: the hardware keycode. This is an identifying number for a 
118   physical key.
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.
128
129 <!-- ##### FUNCTION gdk_keymap_get_default ##### -->
130 <para>
131
132 </para>
133
134 @Returns: 
135
136
137 <!-- ##### FUNCTION gdk_keymap_get_for_display ##### -->
138 <para>
139
140 </para>
141
142 @display: 
143 @Returns: 
144
145
146 <!-- ##### FUNCTION gdk_keymap_lookup_key ##### -->
147 <para>
148
149 </para>
150
151 @keymap: 
152 @key: 
153 @Returns: 
154
155
156 <!-- ##### FUNCTION gdk_keymap_translate_keyboard_state ##### -->
157 <para>
158
159 </para>
160
161 @keymap: 
162 @hardware_keycode: 
163 @state: 
164 @group: 
165 @keyval: 
166 @effective_group: 
167 @level: 
168 @consumed_modifiers: 
169 @Returns: 
170
171
172 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keyval ##### -->
173 <para>
174
175 </para>
176
177 @keymap: 
178 @keyval: 
179 @keys: 
180 @n_keys: 
181 @Returns: 
182
183
184 <!-- ##### FUNCTION gdk_keymap_get_entries_for_keycode ##### -->
185 <para>
186
187 </para>
188
189 @keymap: 
190 @hardware_keycode: 
191 @keys: 
192 @keyvals: 
193 @n_entries: 
194 @Returns: 
195
196
197 <!-- ##### FUNCTION gdk_keymap_get_direction ##### -->
198 <para>
199 Returns the direction of the keymap. 
200 </para>
201
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.
205
206
207 <!-- ##### FUNCTION gdk_keyval_name ##### -->
208 <para>
209 Converts a key value into a symbolic name.
210 The names are the same as those in the <filename>&lt;gdk/gdkkeysyms.h&gt;</filename> header file
211 but without the leading "GDK_".
212 </para>
213
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.
217
218
219 <!-- ##### FUNCTION gdk_keyval_from_name ##### -->
220 <para>
221 Converts a key name to a key value.
222 </para>
223
224 @keyval_name: a key name.
225 @Returns: the corresponding key value, or %GDK_VoidSymbol if the key name is
226 not a valid key.
227
228
229 <!-- ##### FUNCTION gdk_keyval_convert_case ##### -->
230 <para>
231
232 </para>
233
234 @symbol: 
235 @lower: 
236 @upper: 
237
238
239 <!-- ##### FUNCTION gdk_keyval_to_upper ##### -->
240 <para>
241 Converts a key value to upper case, if applicable.
242 </para>
243
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.
247
248
249 <!-- ##### FUNCTION gdk_keyval_to_lower ##### -->
250 <para>
251 Converts a key value to lower case, if applicable.
252 </para>
253
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.
257
258
259 <!-- ##### FUNCTION gdk_keyval_is_upper ##### -->
260 <para>
261 Returns %TRUE if the given key value is in upper case.
262 </para>
263
264 @keyval: a key value.
265 @Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
266 case conversion.
267
268
269 <!-- ##### FUNCTION gdk_keyval_is_lower ##### -->
270 <para>
271 Returns %TRUE if the given key value is in lower case.
272 </para>
273
274 @keyval: a key value.
275 @Returns: %TRUE if @keyval is in lower case, or if @keyval is not subject to
276 case conversion.
277
278
279 <!-- ##### FUNCTION gdk_keyval_to_unicode ##### -->
280 <para>
281
282 </para>
283
284 @keyval: 
285 @Returns: 
286
287
288 <!-- ##### FUNCTION gdk_unicode_to_keyval ##### -->
289 <para>
290
291 </para>
292
293 @wc: 
294 @Returns: 
295
296