1build::Keysyms(3) User Contributed Perl Documentation build::Keysyms(3)
2
3
4
6 Gtk2::Gdk::Keysyms - key codes for Gtk2 programs
7
9 use Gtk2;
10 use Gtk2::Gdk::Keysyms;
11
12 #
13 # the most common use is for deciphering keycodes in key events,
14 # like this:
15 #
16 sub key_press_handler {
17 my ($widget, $event) = @_;
18 if ($event->keyval == $Gtk2::Gdk::Keysyms{Escape}) {
19 abort_whatever ();
20 return 1;
21 }
22 elsif ($event->keyval == $Gtk2::Gdk::Keysyms{F1}) {
23 do_help_thing ();
24 return 1;
25 }
26 elsif ($event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter}) {
27 execute_selected_text_as_command ();
28 return 1;
29 }
30 # we didn't handle it, pass it on...
31 return 0;
32 }
33
35 Gdk defines symbolic names for the codes associated with each key on a
36 keyboard, so that you don't go nuts with numeric values in your
37 programs. The hash %Gtk2::Gdk::Keysyms holds all those keycodes,
38 indexed by the name, for use in your perl programs when you need to do
39 custom key handling. This commonly occurs when you want to bind an
40 action to a key that isn't usable as an accelerator, or when you don't
41 have accelerators, or if you're trying to write an easter egg, or
42 whatever.
43
44 As the list of keycodes is quite large and rather rarely used in
45 application code, we've put it in a separately-loaded module to save
46 space. As an alternative, you might want to investigate
47 "Gtk2::Gdk->keyval_from_name" which offers basically the same
48 functionality as the hash.
49
50 To get a list of all available keys, either dump %Gtk2::Gdk::Keysyms,
51 or look at the source of this module with "perldoc -m
52 Gtk2::Gdk::Keysyms".
53
55 This module was automatically generated by a very simple perl script
56 from gdk/gdkkeysyms.h. Programs that write programs are the happiest
57 programs of all.
58
60 Copyright (C) 2003, 2009 by the gtk2-perl team (see the file AUTHORS
61 for the full list)
62
63 This library is free software; you can redistribute it and/or modify it
64 under the terms of the GNU Library General Public License as published
65 by the Free Software Foundation; either version 2.1 of the License, or
66 (at your option) any later version.
67
68 This library is distributed in the hope that it will be useful, but
69 WITHOUT ANY WARRANTY; without even the implied warranty of
70 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
71 Library General Public License for more details.
72
73 You should have received a copy of the GNU Library General Public
74 License along with this library; if not, write to the Free Software
75 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
76 02110-1301 USA.
77
79 perl, Gtk2, Gtk2::Gdk
80
81
82
83perl v5.38.0 2023-07-20 build::Keysyms(3)