Define constants for keys.
Each key constant is defined as a Key object, which allows comparison with
strings (e.g. ‘A’, ‘Escape’, ‘Shift’). This enables handling of key events
without using the key constants explicitly (e.g.
if ev.key == 'Left':).
In addition, key objects that represent characters can be matched to the integer ordinal (e.g. 32 for space, 65 for A). This behavior is mainly intended as a compatibility measure.
- class vispy.util.keys.Key(*names)¶
Represent the identity of a certain key.
This represents one or more names that the key in question is known by.
A Key object can be compared to one of its string names (case insensitive), to the integer ordinal of the key (only for keys that represent characters), and to another Key instance.
- property name¶
The primary name of the key.