wl_keyboard¤
wayland.wl_keyboard ¤
Keyboard input device
The wl_keyboard interface represents one or more keyboards associated with a seat.
Each wl_keyboard has the following logical state:
- an active surface (possibly null),
- the keys currently logically down,
- the active modifiers,
- the active group.
By default, the active surface is null, the keys currently logically down are empty, the active modifiers and the active group are 0.
Methods:
-
release
–Release the keyboard object
-
on_keymap
–Keyboard mapping.
-
on_enter
–Enter event.
-
on_leave
–Leave event.
-
on_key
–Key event.
-
on_modifiers
–Modifier and group state.
-
on_repeat_info
–Repeat rate and delay.
keymap_format ¤
Keyboard mapping format
This specifies the format of the keymap provided to the client with the wl_keyboard.keymap event.
key_state ¤
Physical key state
Describes the physical state of a key that produced the key event.
Since version 10, the key can be in a "repeated" pseudo-state which means the same as "pressed", but is used to signal repetition in the key event.
The key may only enter the repeated state after entering the pressed state and before entering the released state. This event may be generated multiple times while the key is down.
events
keymap ¤
keymap(format: keymap_format, fd: fd, size: int) -> None
Keyboard mapping
This event provides a file descriptor to the client which can be memory-mapped in read-only mode to provide a keyboard mapping description.
From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the recipient, as MAP_SHARED may fail.
Parameters:
-
format
¤keymap_format
) –Keymap format
-
fd
¤fd
) –Keymap file descriptor
-
size
¤int
) –Keymap size, in bytes
enter ¤
Enter event
Notification that this seat's keyboard focus is on a certain surface.
The compositor must send the wl_keyboard.modifiers event after this event.
In the wl_keyboard logical state, this event sets the active surface to the surface argument and the keys currently logically down to the keys in the keys argument. The compositor must not send this event if the wl_keyboard already had an active surface immediately before this event.
Clients should not use the list of pressed keys to emulate key-press events. The order of keys in the list is unspecified.
Parameters:
leave ¤
leave(serial: int, surface: wl_surface) -> None
Leave event
Notification that this seat's keyboard focus is no longer on a certain surface.
The leave notification is sent before the enter notification for the new focus.
In the wl_keyboard logical state, this event resets all values to their defaults. The compositor must not send this event if the active surface of the wl_keyboard was not equal to the surface argument immediately before this event.
Parameters:
-
serial
¤int
) –Serial number of the leave event
-
surface
¤wl_surface
) –Surface that lost keyboard focus
key ¤
Key event
A key was pressed or released. The time argument is a timestamp with millisecond granularity, with an undefined base.
The key is a platform-specific key code that can be interpreted by feeding it to the keyboard mapping (see the keymap event).
If this event produces a change in modifiers, then the resulting wl_keyboard.modifiers event must be sent after this event.
In the wl_keyboard logical state, this event adds the key to the keys currently logically down (if the state argument is pressed) or removes the key from the keys currently logically down (if the state argument is released). The compositor must not send this event if the wl_keyboard did not have an active surface immediately before this event. The compositor must not send this event if state is pressed (resp. released) and the key was already logically down (resp. was not logically down) immediately before this event.
Since version 10, compositors may send key events with the "repeated" key state when a wl_keyboard.repeat_info event with a rate argument of 0 has been received. This allows the compositor to take over the responsibility of key repetition.
Parameters:
modifiers ¤
modifiers(
serial: int, mods_depressed: int, mods_latched: int, mods_locked: int, group: int
) -> None
Modifier and group state
Notifies clients that the modifier and/or group state has changed, and it should update its local state.
The compositor may send this event without a surface of the client having keyboard focus, for example to tie modifier information to pointer focus instead. If a modifier event with pressed modifiers is sent without a prior enter event, the client can assume the modifier state is valid until it receives the next wl_keyboard.modifiers event. In order to reset the modifier state again, the compositor can send a wl_keyboard.modifiers event with no pressed modifiers.
In the wl_keyboard logical state, this event updates the modifiers and group.
Parameters:
repeat_info ¤
Repeat rate and delay
Informs the client about the keyboard's repeat rate and delay.
This event is sent as soon as the wl_keyboard object has been created, and is guaranteed to be received by the client before any key press event.
Negative values for either rate or delay are illegal. A rate of zero will disable any repeating (regardless of the value of delay).
This event can be sent later on as well with a new value if necessary, so clients should continue listening for the event past the creation of wl_keyboard.
Parameters:
on_keymap ¤
on_keymap(format: keymap_format, fd: fd, size: int) -> None
Keyboard mapping.
Override to handle wayland.wl_keyboard.events.keymap
.
on_enter ¤
on_enter(serial: int, surface: wl_surface, keys: list) -> None
Enter event.
Override to handle wayland.wl_keyboard.events.enter
.
on_leave ¤
on_leave(serial: int, surface: wl_surface) -> None
Leave event.
Override to handle wayland.wl_keyboard.events.leave
.
on_key ¤
Key event.
Override to handle wayland.wl_keyboard.events.key
.
on_modifiers ¤
on_modifiers(
serial: int, mods_depressed: int, mods_latched: int, mods_locked: int, group: int
) -> None
Modifier and group state.
Override to handle wayland.wl_keyboard.events.modifiers
.
on_repeat_info ¤
Repeat rate and delay.
Override to handle wayland.wl_keyboard.events.repeat_info
.