Keyboard

This demo covers the small Tripous keyboard helper API. tp.Keys contains key names based on KeyboardEvent.key, not numeric key codes. Use tp.IsKey() to test a keyboard event against one of those names.

tp.IsPrintableKey() returns true for keys whose event.key is a single character, such as a, 9, or a typed space. It returns false for command keys such as Enter, Escape, arrows, and function keys.

Live keyboard event

Focus the box and press keys. The handler uses tp.IsKey() for command keys and tp.IsPrintableKey() for printable text keys.

Focus here and press keys

Key constants

The constants are plain strings that match browser KeyboardEvent.key values, for example tp.Keys.Escape is Escape.

Simulated command keys

These buttons create standard KeyboardEvent objects so the helper checks can be demonstrated without using the physical keyboard.

Printable keys

Printable detection is based on the final key value. A letter is printable, while Enter is not.