Skip to content


The Key event is sent to a widget when the user presses a key on the keyboard.

  • Bubbles
  • Verbose


attribute type purpose
key str Name of the key that was pressed.
char str or None The character that was pressed, or None it isn't printable.

Code class

def __init__(self, key, character):

Bases: InputEvent

Sent when the user hits a key on the keyboard.

  • Bubbles
  • Verbose
Name Type Description Default
key str

The key that was pressed.

character str | None

A printable character or None if it is not printable.

Name Type Description
aliases list[str]

The aliases for the key, including the key itself.

is_printable property

is_printable: bool

Check if the key is printable (produces a unicode character).

Type Description

True if the key is printable.

name property

name: str

Name of a key suitable for use as a Python identifier.

name_aliases property

name_aliases: list[str]

The corresponding name for every alias in aliases list.