Gtk2::Gdk::Keymap(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– 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:

  • Gtk2
  • Glib::Object

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