Message
KeyEvent
KeyMsg
Bases: Msg
Keyboard event message
Parameters:
-
type
(KeyEvent
) –Keyboard event type
-
shortcut_or_keycodes
(str | Iterable[Key]
) –keyboard shortcut description or event key codes
-
source
(None | KeyIn
, default:None
) –The
KeyIn
instance that generated the message
Tip
Use log to get the shortcuts you need
keycodes
Keycodes in the order they were pressed. Use when pressing order matters.
shortcut
Keyboard shortcut description like 'ctrl+shift+t'
.
Stays the same for any key pressing order.
matches
matches(
type: None | Container[KeyEvent] | KeyEvent = None,
shortcut: None | Container[str] | str = None,
) -> bool
Checks if message's attributes match all provided attribute conditions:
-
If condition is
None
or omitted, it matches anything. -
If condition equals attribute, it matches the attribute.
-
If condition is a container (list, tuple) and contains the attribute, it matches the attribute.
Use Not(condition)
to invert condition matching.
Returns:
-
bool
–True
if all attributes match,False
if any does not match