Gtk2::Gdk::Keymap(3)
π Gtk2::Gdk::Keymap π
okay bestie, welcome to Gtk2::Gdk::Keymap β it's the Perl wrapper for GdkKeymap, and it's literally the thing that knows what your keyboard is doing. this is part of the gtk2-perl docs (User Contributed Perl Documentation, if we're being official about it π
). keyboards, amirite? let's go π
π HIERARCHY π
the family tree, and yes it's giving nepo baby energy:
Glib::Object
+----Gtk2::Gdk::Keymap
β¨ METHODS β¨
π¦ modifiertype = $keymap->add_virtual_modifiers ($state)
$state(Gtk2::Gdk::ModifierType) β hand it a modifier state, it hands one back π«Ά
Since: gtk+ 2.20
π
boolean = $keymap->get_caps_lock_state
no args, no drama. is caps lock on or not, that's the whole vibe.
Since: gtk+ 2.16
πΈ keymap = Gtk2::Gdk::Keymap->get_default
the default keymap, as a class method. the main character of keymaps π
β direction = $keymap->get_direction
tells you which way the text is going. very directional of it.
π§ ({ key1, keyval1 }, { ... }) = $keymap->get_entries_for_keycode (hardware_keycode)
$hardware_keycode(integer) β the raw keycode, the physical one
what you get back is a list of hash references, and each hash has exactly two keys: "key" points at a GdkKeymapKey, and "keyval" points at the matching key value. so like, a little matching set. iconic. π
π keys = $keymap->get_entries_for_keyval (keyval)
$keyval(integer) β the keyval you're curious about
returns a list of GdkKeymapKeys. β¨
so here's the lore: this gives you the list of keycode/group/level combinations that will generate $keyval. and if you're sitting there like "bestie what are groups and levels" β okay so, groups and levels are the two kinds of keyboard mode. generally speaking, the level decides whether you get the top or the bottom symbol on a key, and the group decides whether you get the left or the right symbol. on US keyboards, shift changes the keyboard level and there are simply no groups, periodt. a group switch key could flip your keyboard between Hebrew and English modes, for example. Gtk2::Gdk::Event::Key has a group field in it that tells you the currently active keyboard group. the level, meanwhile, gets computed from the modifier mask. iykyk π
π¦ keymap = Gtk2::Gdk::Keymap->get_for_display ($display)
$display(Gtk2::Gdk::Display) β the display you want the keymap for
Since: gtk+ 2.2
π boolean = $keymap->have_bidi_layouts
does it have bidi layouts? boolean says yes or no, no in-between.
Since: gtk+ 2.12
π₯ integer = $keymap->lookup_key ($key)
$key(scalar) β the key you're looking up
π (bool, new_state) = $keymap->map_virtual_modifiers (keymap, state)
$state(Gtk2::Gdk::ModifierType) β the modifier state going in
Since: gtk+ 2.20
π (keyval, effective_group, level, consumed_modifiers) = $keymap->translate_keyboard_state (hardware_keycode, state, group)
$hardware_keycode(integer)$state(Gtk2::Gdk::ModifierType)$group(integer)
four things come back out. that's the whole deal. π
π SIGNALS π
the keymap is chatty, here's what it's announcing:
direction-changed(Gtk2::Gdk::Keymap)keys-changed(Gtk2::Gdk::Keymap)state-changed(Gtk2::Gdk::Keymap)
πΈ ENUMS AND FLAGS πΈ
π« flags Gtk2::Gdk::ModifierType
every single one, no skips, we don't gatekeep here:
'shift-mask'/'GDK_SHIFT_MASK''lock-mask'/'GDK_LOCK_MASK''control-mask'/'GDK_CONTROL_MASK''mod1-mask'/'GDK_MOD1_MASK''mod2-mask'/'GDK_MOD2_MASK''mod3-mask'/'GDK_MOD3_MASK''mod4-mask'/'GDK_MOD4_MASK''mod5-mask'/'GDK_MOD5_MASK''button1-mask'/'GDK_BUTTON1_MASK''button2-mask'/'GDK_BUTTON2_MASK''button3-mask'/'GDK_BUTTON3_MASK''button4-mask'/'GDK_BUTTON4_MASK''button5-mask'/'GDK_BUTTON5_MASK''super-mask'/'GDK_SUPER_MASK''hyper-mask'/'GDK_HYPER_MASK''meta-mask'/'GDK_META_MASK''release-mask'/'GDK_RELEASE_MASK''modifier-mask'/'GDK_MODIFIER_MASK'
π§ enum Pango::Direction
the directions, in all their flavours:
'ltr'/'PANGO_DIRECTION_LTR''rtl'/'PANGO_DIRECTION_RTL''ttb-ltr'/'PANGO_DIRECTION_TTB_LTR''ttb-rtl'/'PANGO_DIRECTION_TTB_RTL''weak-ltr'/'PANGO_DIRECTION_WEAK_LTR''weak-rtl'/'PANGO_DIRECTION_WEAK_RTL''neutral'/'PANGO_DIRECTION_NEUTRAL'
π SEE ALSO π
go read these next, they're the friends of this page:
Gtk2Glib::Object
π COPYRIGHT π
Copyright (C) 2003-2011 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
and that's the whole page, bestie!! π«Ά this was perl v5.42.0, dated 2025-07-25 β go forth and keyboard, you absolute icon πβ¨π
π¦ where this page comes from
- fedora 43: perl-Gtk2 1.24993-23.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms