Ports
KeyIO
Bases: MultiPort
Keyboard input/output port that combines KeyIn
and
KeyOut
ports.
Produces and sends KeyMsg
objects.
Parameters:
-
supress_input
(bool
, default:False
) –Prevent the input events from being passed to the rest of the system
Warning
Use supress_input
with caution!
You'll lose the keyboard input unless you're proxying it to an output port.
subscribe
subscribe(
type: None | Container[KeyEvent] | KeyEvent = None,
shortcut: None | Container[str] | str = None,
) -> Callable
Decorator to subscribe a callable to all the wrapped inputs' messages.
Decorator without arguments subscribes a callable to all the input's messages.
Decorator with arguments subscribes a callable to the input's messages
that match conditions set by arguments.
It works the same way as message's matches
method:
-
If condition is
None
or omitted it matches anything. -
If condition equals the message's attribute value it matches the attribute.
-
If condition is a container (list, tuple) and contains the message's attribute value, it matches the attribute.
Examples
- Calls function for all MIDI port's messages:
- Calls function for OSC messages from specific address:
- Call object instance method for MIDI port's "note on" and "note off" messages:
Returns:
-
Callable
–Subscribed callable.
KeyIn
Bases: Input
Keyboard input port. Produces KeyMsg
objects.
Parameters:
-
supress_input
(bool
, default:False
) –Prevent the input events from being passed to the rest of the system
Warning
Use supress_input
with caution!
You'll lose the keyboard input unless you're proxying it to an output port.
subscribe
subscribe(
type: None | Container[KeyEvent] | KeyEvent = None,
shortcut: None | Container[str] | str = None,
) -> Callable
Decorator to subscribe a callable to the input's messages.
Decorator without arguments subscribes a callable to all the input's messages.
Decorator with arguments subscribes a callable to the input's messages
that match conditions set by arguments.
It works the same way as message's matches
method:
-
If condition is
None
or omitted it matches anything. -
If condition equals the message's attribute value it matches the attribute.
-
If condition is a container (list, tuple) and contains the message's attribute value, it matches the attribute.
Examples
- Calls function for all MIDI port's messages:
- Calls function for OSC messages from specific address:
- Call object instance method for MIDI port's "note on" and "note off" messages:
Returns:
-
Callable
–Subscribed callable.