KeyPress class final

A pressed keyboard key and its modifier state.

This object is simultaneously what KeyboardDevice emits, and what handlers use to match on keyboard events. Thus, the modifiers mean something slightly different when used as an "event" or a "matcher". This is modestly unintuitive. Sorry!

When emitted by KeyboardDevice as an event, a modifier bool? means:

Value Means
true The modifier was held as the key went down.
false The modifier was not held as the key went down.
null The keyboard never uses this, it's always true or false.

When used as a matcher on Controls.bind, a modifier bool? means:

Value Matches
true Only a press with the modifier held.
false Only a press with the modifier released.
null Any press, whether it was held or released.
Implemented types

Constructors

KeyPress(LogicalKeyboardKey key, {bool? alt, bool? control, bool? shift, bool? meta})
const

Properties

alt → bool?
Whether either alt key must be held, released, or neither.
final
control → bool?
Whether either control key must be held, released, or neither.
final
hashCode → int
The hash code for this object.
no setteroverride
key → LogicalKeyboardKey
The key that went down.
final
meta → bool?
Whether either meta key must be held, released, or neither.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shift → bool?
Whether either shift key must be held, released, or neither.
final

Methods

accepts(ControlEvent emitted) → bool
Whether this event, as something bound to a handler, accepts emitted.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
override