summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gdkkeymap.xml
blob: 1d7c48df1eb97fcc848ca89d53895b9ae87f0428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gdkkeymap">
  <refnamediv>
    <refname>gtk.gdk.Keymap</refname>
    <refpurpose>an object containing mappings of keys to key
values.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.gdk.Keymap</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gdkkeymap--lookup-key">lookup_key</link></methodname>
	<methodparam><parameter role="keyword">keycode</parameter></methodparam>
	<methodparam><parameter role="keyword">group</parameter></methodparam>
	<methodparam><parameter role="keyword">level</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gdkkeymap--translate-keyboard-state">translate_keyboard_state</link></methodname>
	<methodparam><parameter role="keyword">keycode</parameter></methodparam>
	<methodparam><parameter role="keyword">state</parameter></methodparam>
	<methodparam><parameter role="keyword">group</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gdkkeymap--get-entries-for-keyval">get_entries_for_keyval</link></methodname>
	<methodparam><parameter role="keyword">keyval</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gdkkeymap--get-entries-for-keycode">get_entries_for_keycode</link></methodname>
	<methodparam><parameter role="keyword">hardware_keycode</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkkeymap--get-direction">get_direction</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
    </classsynopsis>

    <programlisting>
<emphasis role="bold">Functions</emphasis>

<methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keymap-get-default">gtk.gdk.keymap_get_default</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keymap-get-for-display">gtk.gdk.keymap_get_for_display</link></methodname>
	<methodparam><parameter role="keyword">display</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-name">gtk.gdk.keyval_name</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-from-name">gtk.gdk.keyval_from_name</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval_name</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-convert-case">gtk.gdk.keyval_convert_case</link></methodname>
	<methodparam><parameter
		       role="keyword">symbol</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-to-upper">gtk.gdk.keyval_to_upper</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-to-lower">gtk.gdk.keyval_to_lower</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-is-upper">gtk.gdk.keyval_is_upper</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-is-lower">gtk.gdk.keyval_is_lower</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--keyval-to-unicode">gtk.gdk.keyval_to_unicode</link></methodname>
	<methodparam><parameter
		       role="keyword">keyval</parameter></methodparam>
      </methodsynopsis><methodsynopsis language="python">
	<methodname><link
linkend="function-gdk--unicode-to-keyval">gtk.gdk.unicode_to_keyval</link></methodname>
	<methodparam><parameter role="keyword">wc</parameter></methodparam>
      </methodsynopsis></programlisting>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gdkkeymap">gtk.gdk.Keymap</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Signal Prototypes</title>

    <variablelist>
      <varlistentry>
        <term>"<link linkend="signal-gdkkeymap--direction-changed">direction-changed</link>"</term>
        <listitem>
          <methodsynopsis language="python"><methodname>callback</methodname>
            <methodparam><parameter>gdkkeymap</parameter></methodparam>
            <methodparam><parameter>user_param1</parameter></methodparam>
            <methodparam><parameter>...</parameter></methodparam>
          </methodsynopsis>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term>"<link linkend="signal-gdkkeymap--keys-changed">keys-changed</link>"</term>
        <listitem>
          <methodsynopsis language="python"><methodname>callback</methodname>
            <methodparam><parameter>gdkkeymap</parameter></methodparam>
            <methodparam><parameter>user_param1</parameter></methodparam>
            <methodparam><parameter>...</parameter></methodparam>
          </methodsynopsis>
        </listitem>
      </varlistentry>
    </variablelist>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gdkkeymap"><classname>gtk.gdk.Keymap</classname></link>
defines the translation from keyboard state (including a hardware key, a
modifier mask, and active keyboard group) to a keyval. This translation has
two phases. The first phase is to determine the effective keyboard group and
level for the keyboard state; the second phase is to look up the
keycode/group/level triplet in the keymap and see what keyval it corresponds
to. One <link
linkend="class-gdkkeymap"><classname>gtk.gdk.Keymap</classname></link>
object exists for each user display. <literal>PyGTK</literal> supports only
one display, so <link
linkend="function-gdk--keymap-get-default"><function>gtk.gdk.keymap_get_default()</function>()</link> 
returns the singleton <link
linkend="class-gdkkeymap"><classname>gtk.gdk.Keymap</classname></link>.</para>

    <para>A keymap is a mapping from a Keymap key to key values. You can
think of a Keymap key as a representation of a symbol printed on a physical
keyboard key. That is, it contains three pieces of information. First, it
contains the hardware keycode; this is an identifying number for a physical
key. Second, it contains the level of the key. The 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 exclamation point
("!") character on it. The level indicates whether to use the "1" or the "!"
symbol. The letter keys are considered to have a lowercase letter at level
0, and an uppercase letter at level 1, though only the uppercase letter is
printed. Third, the Keymap key contains a group; groups are not used on
standard US keyboards, but are used in many other countries. On a keyboard
with groups, there can be 3 or 4 symbols printed on a single key. The group
indicates movement in a horizontal direction. Usually groups are used for
two different languages. In group 0, a key might have two English
characters, and in group 1 it might have two Hebrew characters. The Hebrew
characters will be printed on the key next to the English characters.
</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gdkkeymap--lookup-key">
      <title>gtk.gdk.Keymap.lookup_key</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>lookup_key</methodname>
	  <methodparam><parameter
	  role="keyword">keycode</parameter></methodparam>
	  <methodparam><parameter
	  role="keyword">group</parameter></methodparam>
	  <methodparam><parameter
	  role="keyword">level</parameter></methodparam>
	  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">keycode</parameter>&nbsp;:</term>
	  <listitem><simpara>the hardware keycode.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">group</parameter>&nbsp;:</term>
	  <listitem><simpara>the key group</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">level</parameter>&nbsp;:</term>
	  <listitem><simpara>the key level</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a keyval, or 0 if none was mapped to the
	  (<parameter>keycode</parameter>, <parameter>group</parameter>,
	  <parameter>level</parameter>) triplet.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>lookup_key</methodname>() method returns the
keyval mapped to the specified (<parameter>keycode</parameter>,
<parameter>group</parameter>, <parameter>level</parameter>) triplet.  This
method returns 0 if no keyval is found. For normal user input, you want to
use the <link
linkend="method-gdkkeymap--translate-keyboard-state"><methodname>translate_keyboard_state()</methodname></link>
method instead of this method, since the effective group or level may not be
the same as the current keyboard state.</para>

      <para>The parameters to this method are:</para>

      <variablelist>
	<varlistentry>
	  <term><parameter>keycode</parameter>&nbsp;:</term>
	  <listitem>
	    <simpara>the hardware keycode. This is an identifying number for
a physical key.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>group</parameter>&nbsp;:</term>
	  <listitem>
	    <simpara>indicates movement in a horizontal direction. Usually
groups are used for two different languages. In group 0, a key might have
two English characters, and in group 1 it might have two Hebrew
characters. The Hebrew characters will be printed on the key next to the
English characters.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>level</parameter>&nbsp;:</term>
	  <listitem>
	    <simpara>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 exclamation point ("!")  character on it. The level
indicates whether to use the "1" or the "!" symbol. The letter keys are
considered to have a lowercase letter at level 0, and an uppercase letter at
level 1, though only the uppercase letter is printed.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para></para>

    </refsect2>

    <refsect2 id="method-gdkkeymap--translate-keyboard-state">
      <title>gtk.gdk.Keymap.translate_keyboard_state</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>translate_keyboard_state</methodname>
	  <methodparam><parameter role="keyword">keycode</parameter></methodparam>
	  <methodparam><parameter role="keyword">state</parameter></methodparam>
	  <methodparam><parameter role="keyword">group</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">keycode</parameter>&nbsp;:</term>
	  <listitem><simpara>a keycode</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">state</parameter>&nbsp;:</term>
	  <listitem><simpara>a modifier state</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">group</parameter>&nbsp;:</term>
	  <listitem><simpara>an active keyboard group</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem>
	    <simpara>a 4-tuple containing the keyval, the effective group,
the level and the modifiers that were used to determine the group or
level</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>translate_keyboard_state</methodname>() method
translates the contents of a keyboard <link
linkend="class-gdkevent"><classname>gtk.gdk.Event</classname></link>
(specified by <parameter>keycode</parameter>, <parameter>state</parameter>
and <parameter>group</parameter>) into a keyval, effective group, level and
consumed modifiers that affected the translation (and are unavailable for
application use) which are returned in a 4-tuple. See the <link
linkend="method-gdkkeymap--lookup-key"><methodname>lookup_key</methodname>()</link>
method for an explanation of groups and levels. The effective group is the
group that was actually used for the translation; some keys such as
<keycap>Enter</keycap> are not affected by the active keyboard group. The
level is derived from <parameter>state</parameter>. For convenience, the
keyboard <link
linkend="class-gdkevent"><classname>gtk.gdk.Event</classname></link> already
contains the translated keyval, so this method isn't as useful as you might
think.</para>

      <para>The value of <parameter>state</parameter> or the consumed
modifiers is a combination of:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>gtk.gdk.SHIFT_MASK</literal></term>
	  <listitem>
	    <simpara>The Shift key.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.LOCK_MASK</literal></term>
	  <listitem>
	    <simpara>A Lock key (depending on the modifier mapping of the X
server this may either be CapsLock or ShiftLock).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.CONTROL_MASK</literal></term>
	  <listitem>
	    <simpara>The Control key. </simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MOD1_MASK</literal></term>
	  <listitem>
	    <simpara>The fourth modifier key (it depends on the modifier
mapping of the X server which key is interpreted as this modifier, but
normally it is the Alt key).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MOD2_MASK</literal></term>
	  <listitem>
	    <simpara>The fifth modifier key (it depends on the modifier
mapping of the X server which key is interpreted as this
modifier).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MOD3_MASK</literal></term>
	  <listitem>
	    <simpara>The sixth modifier key (it depends on the modifier
mapping of the X server which key is interpreted as this
modifier).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MOD4_MASK</literal></term>
	  <listitem>
	    <simpara>The seventh modifier key (it depends on the modifier
mapping of the X server which key is interpreted as this
modifier).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MOD5_MASK</literal></term>
	  <listitem>
	    <simpara>The eighth modifier key (it depends on the modifier
mapping of the X server which key is interpreted as this
modifier).</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.BUTTON1_MASK</literal></term>
	  <listitem>
	    <simpara>The first mouse button.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.BUTTON2_MASK</literal></term>
	  <listitem>
	    <simpara>The second mouse button.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.BUTTON3_MASK</literal></term>
	  <listitem>
	    <simpara>The third mouse button.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.BUTTON4_MASK</literal></term>
	  <listitem>
	    <simpara>The fourth mouse button.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.BUTTON5_MASK</literal></term>
	  <listitem>
	    <simpara>The fifth mouse button.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.RELEASE_MASK</literal></term>
	  <listitem>
	    <simpara>Differentiates between (keyval, modifiers) pairs from
key press and release events.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>gtk.gdk.MODIFIER_MASK</literal></term>
	  <listitem>
	    <simpara>all of the above</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para></para>

      <refsect3>
	<title>Consumed Modifiers</title>

	<para>The consumed modifiers are modifiers that should be masked out
from <parameter>state</parameter> when comparing this key press to a hot
key. For instance, on a US keyboard, the <keysym>plus</keysym> symbol is
shifted, so when comparing a key press to a
<keycombo>
	    <keycap>Control</keycap><keysym>plus</keysym></keycombo>
	    accelerator <keycap>Shift</keycap> should be masked out. For
	    example:</para>

	<programlisting>
  # We want to ignore irrelevant modifiers like ScrollLock
  ALL_ACCELS_MASK = (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
                     | gtk.gdk.MOD1_MASK)
  keyval, egroup, level, consumed = keymap.translate_keyboard_state(
                   event.hardware_keycode, event.state, event.group)
  if (keyval == gtk.keysyms.plus and 
      (event.state &amp; ~consumed &amp; ALL_ACCELS_MASK) == gtk.gdk.CONTROL_MASK):
    # Control was pressed
</programlisting>

        <para>Note that most keys that are affected by the
<keycap>Shift</keycap> key will have <literal>gtk.gdk.SHIFT_MASK</literal>
part of the consumed modifiers (e.g. <keycombo>
<keycap>Control</keycap><keycap>Shift</keycap><keycap>Tab</keycap>
</keycombo>).</para>

	<para>All single modifier combinations that could affect the key for
any combination of modifiers will be returned in consumed_modifiers.
Multi-modifier combinations are returned only when actually found in
<parameter>state</parameter>. When you store accelerators, you should always
store them with consumed modifiers removed. Store &lt;Control&gt;plus, not
&lt;Control&gt;&lt;Shift&gt;plus,</para>

      </refsect3>

    </refsect2>

  <refsect2 id="method-gdkkeymap--get-entries-for-keyval">
    <title>gtk.gdk.Keymap.get_entries_for_keyval</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_entries_for_keyval</methodname>
	  <methodparam><parameter role="keyword">keyval</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
	  <listitem><simpara>a keyval, such as <literal>GDK_a</literal>,
<literal>GDK_Up</literal>, <literal>GDK_Return</literal>,
etc.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a tuple containing 3-tuple containing a keycode,
a group and a level that will generate
<parameter>keyval</parameter>.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_entries_for_keyval</methodname>() method
returns a tuple of (keycode, group, level) 3-tuples that will generate
<parameter>keyval</parameter>. Groups and levels are two kinds of keyboard
mode; in general, the level determines whether the top or bottom symbol on a
key is used, and the group determines whether the left or right symbol is
used. On US keyboards, the shift key changes the keyboard level, and there
are no groups. A group switch key might convert a keyboard between Hebrew to
English modes, for example, the <literal>gtk.gdk.KEY_PRESS</literal> and
<literal>gtk.gdk.KEY_RELEASE</literal> <link
linkend="class-gdkevent"><classname>gtk.gdk.Event</classname></link> objects
contain a <literal>group</literal> attribute that indicates the active
keyboard group. The level is computed from the modifier mask.</para>

    </refsect2>

  <refsect2 id="method-gdkkeymap--get-entries-for-keycode">
    <title>gtk.gdk.Keymap.get_entries_for_keycode</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_entries_for_keycode</methodname>
	  <methodparam><parameter role="keyword">hardware_keycode</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">hardware_keycode</parameter>&nbsp;:</term>
	  <listitem><simpara>a keycode</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a tuple containing 4-tuples: (keyval, keycode,
group, level)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_entries_for_keycode</methodname>() method
returns a tuple containing 4-tuples with: the keyvals bound to
<parameter>hardware_keycode</parameter>, the keycode, the group and the
level.  When a keycode is pressed by the user, the keyval from this list of
entries is selected by considering the effective keyboard group and
level. See the <link
linkend="method-gdkkeymap--translate-keyboard-state"><methodname>translate_keyboard_state()</methodname></link>
method for more information.</para>

    </refsect2>

    <refsect2 id="method-gdkkeymap--get-direction">
    <title>gtk.gdk.Keymap.get_direction</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_direction</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a Pango direction: <literal>pango.DIRECTION_LTR</literal> or <literal>pango.DIRECTION_RTL</literal>.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_direction</methodname>() method returns the direction of the keymap.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Functions</title>

    <refsect2 id="function-gdk--keymap-get-default">
      <title>gtk.gdk.keymap_get_default</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keymap_get_default</methodname>
          <methodparam></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the default gdk keymap for the
display.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keymap_get_default</function>() function
returns the default <link
linkend="class-gdkkeymap"><classname>gtk.gdk.Keymap</classname></link> for
the display.</para>

    </refsect2>

    <refsect2 id="function-gdk--keymap-get-for-display">
      <title>gtk.gdk.keymap_get_for_display</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keymap_get_for_display</methodname>
	<methodparam><parameter role="keyword">display</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">display</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link linkend="class-gdkdisplay"><classname>gtk.gdk.Display</classname></link></simpara></listitem>
	</varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the keymap for
          <parameter>display</parameter>.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <note>
	<para>This function is available in PyGTK 2.2 and above.</para>
      </note>

      <para>The <function>gtk.gdk.keymap_get_for_display</function>()
function returns the <link
linkend="class-gdkkeymap"><classname>gtk.gdk.Keymap</classname></link> for
the <link
linkend="class-gdkdisplay"><classname>gtk.gdk.Display</classname></link>
specified by <parameter>display</parameter>.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-name">
      <title>gtk.gdk.keyval_name</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_name</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>a key value</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>a string containing the name of the key, or
None if keyval is not a valid key.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_name</function>() function converts
the key value specified by <parameter>keyval</parameter> into a symbolic
name.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-from-name">
      <title>gtk.gdk.keyval_from_name</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_from_name</methodname>
          <methodparam><parameter
			 role="keyword">keyval_name</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter
role="keyword">keyval_name</parameter>&nbsp;:</term>
          <listitem><simpara>a key name</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the corresponding key value or 0 if the key
name is not a valid key.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_from_name</function>() function
converts the key name specified by <parameter>keyval_name</parameter> to a
key value.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-convert-case">
      <title>gtk.gdk.keyval_convert_case</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_convert_case</methodname>
          <methodparam><parameter
			 role="keyword">symbol</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter
role="keyword">symbol</parameter>&nbsp;:</term>
          <listitem><simpara>a keyval</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>a 2-tuple containing the lowercase and
          uppercase versions of
          <parameter>symbol</parameter></simpara></listitem>
        </varlistentry>
      </variablelist>

      <note>
	<para>This function is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <function>gtk.gdk.keyval_convert_case</function>() function
returns the lowercase and uppercase versions of the keyval specified by
<parameter>symbol</parameter>.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-to-upper">
      <title>gtk.gdk.keyval_to_upper</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_to_upper</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>a key value.</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the upper case form of keyval, or keyval itself
if it is already in upper case or it is not subject to case
conversion.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_to_upper</function>() function
converts the key value specified by <parameter>keyval</parameter> to upper
case, if applicable.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-to-lower">
      <title>gtk.gdk.keyval_to_lower</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_to_lower</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>the key value</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the lower case form of keyval, or keyval itself
if it is already in lower case or it is not subject to case
conversion.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_to_lower</function>() function
converts the key value specified by <parameter>keyval</parameter> to lower
case, if applicable. </para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-is-upper">
      <title>gtk.gdk.keyval_is_upper</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_is_upper</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>the key value</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara><literal>TRUE</literal> if
<parameter>keyval</parameter> is in upper case or if keyval is not subject
to case conversion.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_is_upper</function>() function
returns <literal>TRUE</literal> if the key value specified by
<parameter>keyval</parameter> is in upper case or not subject to case
conversion.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-is-lower">
      <title>gtk.gdk.keyval_is_lower</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_is_lower</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>the key value</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara><literal>TRUE</literal> if
<parameter>keyval</parameter> is in lower case, or if
<parameter>keyval</parameter> is not subject to case
conversion.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_is_lower</function>() function
returns <literal>TRUE</literal> if the key value specified by
<parameter>keyval</parameter> is in lower case or is not subject to case
conversion.</para>

    </refsect2>

    <refsect2 id="function-gdk--keyval-to-unicode">
      <title>gtk.gdk.keyval_to_unicode</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.keyval_to_unicode</methodname>
          <methodparam><parameter
			 role="keyword">keyval</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">keyval</parameter>&nbsp;:</term>
          <listitem><simpara>the key value</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara> the corresponding unicode character, or 0 if
there is no corresponding character.</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.keyval_to_unicode</function>() function
converts the key value specified by <parameter>keyval</parameter> to the
corresponding ISO10646 (Unicode) character.</para>

    </refsect2>

    <refsect2 id="function-gdk--unicode-to-keyval">
      <title>gtk.gdk.unicode_to_keyval</title>

      <programlisting><methodsynopsis language="python">
          <methodname>gtk.gdk.unicode_to_keyval</methodname>
          <methodparam><parameter
			 role="keyword">wc</parameter></methodparam>
        </methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
          <term><parameter role="keyword">wc</parameter>&nbsp;:</term>
          <listitem><simpara> a ISO10646 encoded (unicode)
character</simpara></listitem>
        </varlistentry>
        <varlistentry>
          <term><emphasis>Returns</emphasis>&nbsp;:</term>
          <listitem><simpara>the corresponding key value, if one exists. or,
if there is no corresponding symbol, <parameter>wc</parameter> |
0x01000000</simpara></listitem>
        </varlistentry>
      </variablelist>

      <para>The <function>gtk.gdk.unicode_to_keyval</function>() function
converts the ISO10646 (unicode) character specified by
<parameter>wc</parameter> to a key value.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Signals</title>

    <refsect2 id="signal-gdkkeymap--direction-changed">
      <title>The "direction-changed" gtk.gdk.Keymap Signal</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>callback</methodname>
	  <methodparam><parameter>gdkkeymap</parameter></methodparam>
	  <methodparam><parameter>user_param1</parameter></methodparam>
	  <methodparam><parameter>...</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
	  <term><parameter>gdkkeymap</parameter>&nbsp;:</term>
	  <listitem><simpara>the gdkkeymap that received the
signal</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>user_param1</parameter>&nbsp;:</term>
          <listitem><simpara>the first user parameter (if any) specified
with the <link
linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
method</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>...</parameter>&nbsp;:</term>
	  <listitem><simpara>additional user parameters (if
any)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The "direction-changed" signal is emitted when the pango text
direction of <parameter>gdkkeymap</parameter> is changed</para>

    </refsect2>

    <refsect2 id="signal-gdkkeymap--keys-changed">
      <title>The "keys-changed" gtk.gdk.Keymap Signal</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>callback</methodname>
	  <methodparam><parameter>gdkkeymap</parameter></methodparam>
	  <methodparam><parameter>user_param1</parameter></methodparam>
	  <methodparam><parameter>...</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
	  <term><parameter>gdkkeymap</parameter>&nbsp;:</term>
	  <listitem><simpara>the gdkkeymap that received the
signal</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>user_param1</parameter>&nbsp;:</term>
          <listitem><simpara>the first user parameter (if any) specified
with the <link
linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
method</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>...</parameter>&nbsp;:</term>
	  <listitem><simpara>additional user parameters (if
any)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This signal is available in GTK+ 2.2 and above.</para>
      </note>

      <para>The "keys-changed" signal is emitted when the mapping
represented by <parameter>keymap</parameter> changes.</para>

    </refsect2>

  </refsect1>

</refentry>