KeyInfo
Preview notice
The MatrixOS Python API is in preview and is subject to change; it may contain errors.
Overview
The KeyInfo class contains detailed information about a key's state, including timing data, force/pressure, and activity status. It provides methods to query key behavior and detect various input patterns.
The Python KeyInfo class is implemented in Applications/Python/PikaPython/MatrixOS_KeyInfo.py with type hints in Applications/Python/PikaPython/_MatrixOS_KeyInfo.pyi.
Constructor
KeyInfo(*val)
def __init__(self, *val) -> None
Creates a KeyInfo instance with variable arguments.
Parameters:
*val: Variable arguments for initialization
Methods
State
def State(self) -> int
Gets the current key state value.
Returns:
int: The key state (corresponds to KeyState enum values)
Force
def Force(self) -> float
Gets the force/pressure applied to the key.
Returns:
float: Force value (0.0 to 1.0)
Value
def Value(self, index: int = 0) -> float
Gets a specific value from the key information.
Parameters:
index(int, optional): Value index (default: 0)
Returns:
float: Value at specified index
LastEventTime
def LastEventTime(self) -> int
Gets the timestamp of the last key event.
Returns:
int: Timestamp in milliseconds of the last event
Hold
def Hold(self) -> bool
Checks if the key is being held down.
Returns:
bool: True if key is being held, False otherwise
Active
def Active(self) -> bool
Checks if the key is currently active (pressed).
Returns:
bool: True if key is active/pressed, False otherwise
HoldTime
def HoldTime(self) -> int
Gets the duration the key has been held down.
Returns:
int: Hold duration in milliseconds
__bool__
def __bool__(self) -> bool
Allows KeyInfo to be used in boolean contexts.
Returns:
bool: True if KeyInfo represents a valid key state
Comments