TTkKeyEvent🌶️

class TTkKeyEvent(key: int | str, code: str, mod: int)[source]🌶️

Bases: object

Keyboard event base class.

Demo:

test.input.py

Parsed input is exposed as one of the concrete subclasses: TTkKeyEvent_Character for literal character input and TTkKeyEvent_SpecialKey for translated terminal sequences.

The shared key attribute stores the payload for the concrete event type: a str for TTkKeyEvent_Character and an int TTkK constant for TTkKeyEvent_SpecialKey.

Parameters:
  • code (str) – The terminal code used to represent this input

  • mod (TTkConstant.KeyModifier) – The modifier used by the SpecialKey type

key: str | int🌶️

The parsed key payload for the concrete event instance.

code: str🌶️

The terminal code used to represent this input

mod: KeyModifier🌶️

The TTkConstant.KeyModifier associated with the input.

Methods🌶️

static parse(input_key)[source]🌶️

Parse raw terminal input into a typed key event.

Parameters:

input_key (str) – The raw terminal input sequence.

Returns:

A character event, a special-key event, or None when the sequence is not recognized.

Return type:

TTkKeyEvent_Character | TTkKeyEvent_SpecialKey | None

TTkKeyEvent Attributes🌶️