Skip to main content
Version: Matrix OS 3.2

KeyEvent

Preview notice

The MatrixOS Python API is in preview and is subject to change; it may contain errors.

Overview

The KeyEvent class represents an event triggered by key input interaction. KeyEvent objects are typically obtained from MatrixOS.KeyPad.Get() and provide direct access to key state, force, timing, and other input properties.

The Python KeyEvent class is implemented in Applications/Python/PikaPython/MatrixOS_KeyEvent.py with type hints in Applications/Python/PikaPython/_MatrixOS_KeyEvent.pyi.


Methods

ID

def ID(self) -> int

Gets the unique identifier for this key event.

Returns:

  • int: The key ID

State

def State(self) -> int

Gets the current state of the key.

Returns:

  • int: Key state value

Hold

def Hold(self) -> bool

Checks if the key is being held.

Returns:

  • bool: True if key is held

HoldTime

def HoldTime(self) -> int

Gets the time the key has been held in milliseconds.

Returns:

  • int: Hold time in milliseconds

Active

def Active(self) -> bool

Checks if the key is currently active (pressed).

Returns:

  • bool: True if key is active

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 event.

Parameters:

  • index (int, optional): Value index (default: 0)

Returns:

  • float: Value at specified index

__bool__

def __bool__(self) -> bool

Allows KeyEvent to be used in boolean context.

Returns:

  • bool: True if event is valid

Comments