Skip to content
docsv0.3.0

Key

Builder of canonical key ids for use with {@see KeyMatcher::matches()}. The PHP analog of pi-tui's `Key` helper. Each method returns a string id in the exact format {@see KeyMatcher::canonicalId()} expects, so callers never have to remember the modifier order or the alias names. Usage: KeyMatcher::matches($raw, Key::ctrl('c')) KeyMatcher::matches($raw, Key::shift('tab')) KeyMatcher::matches($raw, Key::alt('left')) KeyMatcher::matches($raw, Key::ctrlShift('p')) The bare special-key constants (`Key::ENTER`, `Key::ESCAPE`, …) are the same strings pi-tui uses so behavior transfers across ports.

Key::printableCharacter()

public static function printableCharacter(string $key): ?string

The character this key produces, or null when it is not a printable one.

Parameters

Parameters of printableCharacter()
NameTypeDescription
$keystring

Key::ctrl()

public static function ctrl(string $key): string

The key name for this key held with Control.

Parameters

Parameters of ctrl()
NameTypeDescription
$keystring

Key::shift()

public static function shift(string $key): string

The key name for this key held with Shift.

Parameters

Parameters of shift()
NameTypeDescription
$keystring

Key::alt()

public static function alt(string $key): string

The key name for this key held with Alt.

Parameters

Parameters of alt()
NameTypeDescription
$keystring

Key::meta()

public static function meta(string $key): string

The key name for this key held with Meta.

Parameters

Parameters of meta()
NameTypeDescription
$keystring

Key::ctrlShift()

public static function ctrlShift(string $key): string

The key name for this key held with Control and Shift.

Parameters

Parameters of ctrlShift()
NameTypeDescription
$keystring

Key::ctrlAlt()

public static function ctrlAlt(string $key): string

The key name for this key held with Control and Alt.

Parameters

Parameters of ctrlAlt()
NameTypeDescription
$keystring

Key::shiftAlt()

public static function shiftAlt(string $key): string

The key name for this key held with Shift and Alt.

Parameters

Parameters of shiftAlt()
NameTypeDescription
$keystring