EventControllerKey

class EventControllerKey(**properties: Any)

Superclasses: EventController, Object

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

Constructors

class EventControllerKey
classmethod new() EventController

Creates a new event controller that will handle key events.

Methods

class EventControllerKey
forward(widget: Widget) bool

Forwards the current event of this controller to a widget.

This function can only be used in handlers for the key_pressed, key_released or modifiers signals.

Parameters:

widget – a GtkWidget

get_group() int

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

See get_layout.

get_im_context() IMContext | None

Gets the input method context of the key controller.

set_im_context(im_context: IMContext | None = None) None

Sets the input method context of the key controller.

Parameters:

im_context – a GtkIMContext

Signals

class EventControllerKey.signals
im_update() None

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

See set_im_context and filter_keypress.

key_pressed(keyval: int, keycode: int, state: ModifierType) bool

Emitted whenever a key is pressed.

Parameters:
  • keyval – the pressed key.

  • keycode – the raw code of the pressed key.

  • state – the bitmask, representing the state of modifier keys and pointer buttons.

key_released(keyval: int, keycode: int, state: ModifierType) None

Emitted whenever a key is released.

Parameters:
  • keyval – the released key.

  • keycode – the raw code of the released key.

  • state – the bitmask, representing the state of modifier keys and pointer buttons.

modifiers(state: ModifierType) bool

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

Parameters:

state – the bitmask, representing the new state of modifier keys and pointer buttons.