wijjit.terminal.input.Key

class wijjit.terminal.input.Key(name, key_type, char=None)[source]

Represents a keyboard key press.

Parameters:
  • name (str) – Name of the key (e.g., ‘a’, ‘enter’, ‘up’, ‘ctrl+c’)

  • key_type (KeyType) – Type of key press

  • char (str, optional) – Character representation if applicable

__init__(name, key_type, char=None)
Parameters:
Return type:

None

Methods

__init__(name, key_type[, char])

Attributes

char

is_char

Check if this is a character key.

is_control

Check if this is a control key.

is_ctrl_c

Check if this is Ctrl+C.

is_special

Check if this is a special key.

modifiers

Get list of modifiers for this key.

name

key_type

name: str
key_type: KeyType
char: str | None = None
__str__()[source]

String representation of the key.

Returns:

Key name

Return type:

str

property is_char: bool

Check if this is a character key.

Returns:

True if character key

Return type:

bool

property is_special: bool

Check if this is a special key.

Returns:

True if special key

Return type:

bool

property is_control: bool

Check if this is a control key.

Returns:

True if control key

Return type:

bool

property is_ctrl_c: bool

Check if this is Ctrl+C.

Returns:

True if Ctrl+C

Return type:

bool

property modifiers: list[str]

Get list of modifiers for this key.

Returns:

List of modifier names (e.g., [‘ctrl’], [‘alt’], etc.)

Return type:

list