VirtualKey class

Represents a single key on the virtual keyboard or keypad.

Use VirtualKey.character for keys that insert text, or VirtualKey.action for special function keys like backspace, enter, and shift.

Constructors

VirtualKey.action({required KeyAction action, String? text, String? label, String? altLabel, double flex = 1.0})
Creates an action key that performs a keyboard function.
VirtualKey.character({required String? text, String? capsText, double flex = 1.0})
Creates a character key that inserts text.

Properties

action KeyAction?
The action for action keys, null for character keys.
final
altLabel String?
Alternate label for action keys when on non-primary layout. For example, "কখ" for Bengali, "ABC" for English.
final
capsText String?
The uppercase/shifted text for this key.
final
flex double
Relative width multiplier for the key. A flex of 2 means twice the width. Supports fractional values like 1.5 for fine-grained sizing.
final
hashCode int
The hash code for this object.
no setterinherited
isAction bool
Returns true if this is an action key.
no setter
isCharacter bool
Returns true if this is a character key.
no setter
keyType KeyType
Whether this is a character or action key.
final
label String?
Label for action keys when on primary layout. For example, "123" on the symbols button.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String?
The primary text character for this key.
final

Methods

getDisplayText({bool shift = false, bool capsLock = false}) String
Gets the text to display on the key.
getInsertText({bool shift = false, bool capsLock = false}) String
Gets the text to insert when this key is pressed.
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.
inherited