Message
KeyEvent
KeyMsg
KeyMsg(
type: KeyEvent,
shortcut_or_keycodes: str | Iterable[pynput.keyboard.Key],
*,
source: None | KeyIn = None
)
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
Run GUI and enable keyboard input. Use log to get messages with shortcuts you need.
shortcut
Keyboard shortcut description like 'ctrl+shift+t'
.
Stays the same for any key press 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 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