Gtk.EventControllerKey

g GObject.Object GObject.Object Gtk.EventController Gtk.EventController GObject.Object->Gtk.EventController Gtk.EventControllerKey Gtk.EventControllerKey Gtk.EventController->Gtk.EventControllerKey

Subclasses:

None

Methods

Inherited:

Gtk.EventController (13), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

forward (widget)

get_group ()

get_im_context ()

set_im_context (im_context)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Gtk.EventController (4)

Signals

Inherited:

GObject.Object (1)

Name

Short Description

im-update

Emitted whenever the input method context filters away a keypress and prevents the controller receiving it.

key-pressed

Emitted whenever a key is pressed.

key-released

Emitted whenever a key is released.

modifiers

Emitted whenever the state of modifier keys and pointer buttons change.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.EventControllerKey(**kwargs)
Bases:

Gtk.EventController

Abstract:

No

Structure:

Gtk.EventControllerKeyClass

GtkEventControllerKey is an event controller that provides access to key events.

classmethod new()[source]
Returns:

a new GtkEventControllerKey

Return type:

Gtk.EventController

Creates a new event controller that will handle key events.

forward(widget)[source]
Parameters:

widget (Gtk.Widget) – a GtkWidget

Returns:

whether the widget handled the event

Return type:

bool

Forwards the current event of this self to a widget.

This function can only be used in handlers for the [signal`Gtk`.EventControllerKey::key-pressed], [signal`Gtk`.EventControllerKey::key-released] or [signal`Gtk`.EventControllerKey::modifiers] signals.

get_group()[source]
Returns:

the key group

Return type:

int

Gets the key group of the current event of this self.

See [method`Gdk`.KeyEvent.get_layout].

get_im_context()[source]
Returns:

the GtkIMContext

Return type:

Gtk.IMContext or None

Gets the input method context of the key self.

set_im_context(im_context)[source]
Parameters:

im_context (Gtk.IMContext or None) – a GtkIMContext

Sets the input method context of the key self.

Signal Details

Gtk.EventControllerKey.signals.im_update(event_controller_key)
Signal Name:

im-update

Flags:

RUN_LAST

Parameters:

event_controller_key (Gtk.EventControllerKey) – The object which received the signal

Emitted whenever the input method context filters away a keypress and prevents the controller receiving it.

See [method`Gtk`.EventControllerKey.set_im_context] and [method`Gtk`.IMContext.filter_keypress].

Gtk.EventControllerKey.signals.key_pressed(event_controller_key, keyval, keycode, state)
Signal Name:

key-pressed

Flags:

RUN_LAST

Parameters:
  • event_controller_key (Gtk.EventControllerKey) – The object which received the signal

  • keyval (int) – the pressed key.

  • keycode (int) – the raw code of the pressed key.

  • state (Gdk.ModifierType) – the bitmask, representing the state of modifier keys and pointer buttons.

Returns:

True if the key press was handled, False otherwise.

Return type:

bool

Emitted whenever a key is pressed.

Gtk.EventControllerKey.signals.key_released(event_controller_key, keyval, keycode, state)
Signal Name:

key-released

Flags:

RUN_LAST

Parameters:
  • event_controller_key (Gtk.EventControllerKey) – The object which received the signal

  • keyval (int) – the released key.

  • keycode (int) – the raw code of the released key.

  • state (Gdk.ModifierType) – the bitmask, representing the state of modifier keys and pointer buttons.

Emitted whenever a key is released.

Gtk.EventControllerKey.signals.modifiers(event_controller_key, state)
Signal Name:

modifiers

Flags:

RUN_LAST

Parameters:
  • event_controller_key (Gtk.EventControllerKey) – The object which received the signal

  • state (Gdk.ModifierType) – the bitmask, representing the new state of modifier keys and pointer buttons.

Return type:

bool

Emitted whenever the state of modifier keys and pointer buttons change.