Skip to main content
Version: Matrix OS 3.2

Keyboard API

Preview notice

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

Overview

The HID Keyboard interface allows the device to emulate a standard USB keyboard, sending key press and release events to connected hosts. This enables text input, keyboard shortcuts, and comprehensive keyboard functionality.

The Python HID Keyboard API is implemented in Applications/Python/PikaPython/MatrixOS_HID_Keyboard.py with type hints in Applications/Python/PikaPython/_MatrixOS_HID_Keyboard.pyi.


MatrixOS.HID.Keyboard.Tap

def Tap(keycode: KeyboardKeycode, length_ms: int = 100) -> bool

Sends a complete keystroke (key press followed by key release) with configurable duration.

Parameters:

  • keycode (KeyboardKeycode): Key to press and release
  • length_ms (int, optional): Duration to hold key in milliseconds (defaults to 100)

Returns:

  • bool: True if successful

MatrixOS.HID.Keyboard.Press

def Press(keycode: KeyboardKeycode) -> bool

Presses a key (key down event) without releasing it.

Parameters:

  • keycode (KeyboardKeycode): Key to press

Returns:

  • bool: True if successful

MatrixOS.HID.Keyboard.Release

def Release(keycode: KeyboardKeycode) -> bool

Releases a previously pressed key (key up event).

Parameters:

  • keycode (KeyboardKeycode): Key to release

Returns:

  • bool: True if successful

MatrixOS.HID.Keyboard.ReleaseAll

def ReleaseAll() -> None

Releases all currently pressed keys.


Keyboard Keycodes Reference

Common keyboard keycodes available in KeyboardKeycode:

Letters

  • KEY_A through KEY_Z: Letter keys

Numbers

  • KEY_1 through KEY_0: Number row keys
  • KEY_KEYPAD_1 through KEY_KEYPAD_0: Numpad keys

Modifiers

  • KEY_LEFT_CTRL, KEY_RIGHT_CTRL: Control keys
  • KEY_LEFT_SHIFT, KEY_RIGHT_SHIFT: Shift keys
  • KEY_LEFT_ALT, KEY_RIGHT_ALT: Alt keys
  • KEY_LEFT_GUI, KEY_RIGHT_GUI: Windows/Cmd keys

Special Keys

  • KEY_ENTER: Enter key
  • KEY_ESCAPE: Escape key
  • KEY_BACKSPACE: Backspace key
  • KEY_TAB: Tab key
  • KEY_SPACE: Space bar
  • KEY_DELETE: Delete key

Function Keys

  • KEY_F1 through KEY_F12: Function keys

Arrow Keys

  • KEY_RIGHT_ARROW, KEY_LEFT_ARROW
  • KEY_DOWN_ARROW, KEY_UP_ARROW
  • KEY_PAGE_UP, KEY_PAGE_DOWN
  • KEY_HOME, KEY_END
  • KEY_INSERT

Media Keys (device dependent)

  • KEY_VOLUME_UP, KEY_VOLUME_DOWN
  • KEY_MUTE

Punctuation

  • KEY_PERIOD, KEY_COMMA
  • KEY_SEMICOLON, KEY_APOSTROPHE
  • KEY_SLASH, KEY_BACKSLASH
  • KEY_MINUS, KEY_EQUAL

Comments