:right-sidebar: True EventControllerKey =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: EventControllerKey(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.EventController`, :class:`~gi.repository.GObject.Object` ``GtkEventControllerKey`` is an event controller that provides access to key events. Constructors ------------ .. rst-class:: interim-class .. class:: EventControllerKey :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.EventController Creates a new event controller that will handle key events. Methods ------- .. rst-class:: interim-class .. class:: EventControllerKey :no-index: .. method:: forward(widget: ~gi.repository.Gtk.Widget) -> bool Forwards the current event of this ``controller`` to a ``widget``. This function can only be used in handlers for the :obj:`~gi.repository.Gtk.EventControllerKey.signals.key_pressed`, :obj:`~gi.repository.Gtk.EventControllerKey.signals.key_released` or :obj:`~gi.repository.Gtk.EventControllerKey.signals.modifiers` signals. :param widget: a ``GtkWidget`` .. method:: get_group() -> int Gets the key group of the current event of this ``controller``. See :obj:`~gi.repository.Gdk.KeyEvent.get_layout`. .. method:: get_im_context() -> ~gi.repository.Gtk.IMContext | None Gets the input method context of the key ``controller``. .. method:: set_im_context(im_context: ~gi.repository.Gtk.IMContext | None = None) -> None Sets the input method context of the key ``controller``. :param im_context: a ``GtkIMContext`` Signals ------- .. rst-class:: interim-class .. class:: EventControllerKey.signals :no-index: .. method:: im_update() -> None Emitted whenever the input method context filters away a keypress and prevents the ``controller`` receiving it. See :obj:`~gi.repository.Gtk.EventControllerKey.set_im_context` and :obj:`~gi.repository.Gtk.IMContext.filter_keypress`. .. method:: key_pressed(keyval: int, keycode: int, state: ~gi.repository.Gdk.ModifierType) -> bool Emitted whenever a key is pressed. :param keyval: the pressed key. :param keycode: the raw code of the pressed key. :param state: the bitmask, representing the state of modifier keys and pointer buttons. .. method:: key_released(keyval: int, keycode: int, state: ~gi.repository.Gdk.ModifierType) -> None Emitted whenever a key is released. :param keyval: the released key. :param keycode: the raw code of the released key. :param state: the bitmask, representing the state of modifier keys and pointer buttons. .. method:: modifiers(state: ~gi.repository.Gdk.ModifierType) -> bool Emitted whenever the state of modifier keys and pointer buttons change. :param state: the bitmask, representing the new state of modifier keys and pointer buttons.