KeySequence class sealed

A pattern that matches one or more keypresses — the value a KeyBinding binds and the InputDispatcher matches events against.

A sequence is one or more steps; each step is one KeyCode plus a strict set of modifiers, and the dispatcher consumes one KeyEvent per step. KeyCode is the one-step, unmodified subtype — .enter and .char('?') are sequences directly — while modified or multi-step patterns are built with the dot chain:

.enter                 // a KeyCode — one unmodified key
.ctrl.s                // one modified step
.ctrl.shift.p          // stacked modifiers (order-agnostic)
.superKey.k            // super/meta are first-class
.g.g                   // a two-step sequence
.ctrl.x.ctrl.s         // emacs-style multi-step
.space.f               // leader style
.alt.char('${1 + 1}')  // dynamic atoms via char()

Modifiers fold into the next key atom; an expression ending in a modifier has type PendingKeySequence, not KeySequence, so KeyBinding(.ctrl) is a compile error.

Sequences are values: structural, canonicalised equality (.shift.g, .char('G'), and .char('g', …) are one value) makes them safe as Map<KeySequence, _> keys and for KeyBinding alias dedup.

sealed rather than final: the only non-KeyCode subtype is private, so external code can't exhaustively switch anyway (it always needs a default), and sealing lets the two subtypes share one step interface.

Implementers
Available extensions

Properties

a → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
alt → PendingKeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
b → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
backspace → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
c → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
ctrl → PendingKeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
d → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
delete → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
down → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
e → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
end → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
enter → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
escape → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f1 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f10 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f11 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f12 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f2 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f3 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f4 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f5 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f6 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f7 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f8 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
f9 → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
g → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
h → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
hashCode → int
The hash code for this object.
no setteroverride
hintLabel → String
Short human-readable label: j / Ctrl+S / ↑ / Ctrl+X Ctrl+S. Round-trips through parse.
no setter
home → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
i → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
insert → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
j → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
k → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
l → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
left → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
m → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
meta → PendingKeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
n → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
o → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
p → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
pageDown → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
pageUp → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
q → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
r → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter

Available on KeySequence, provided by the KeySequenceChain extension

no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
s → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
shift → PendingKeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
space → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
stepCount → int
Number of steps (1 for a single-keystroke sequence).
no setter
superKey → PendingKeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
t → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
tab → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
u → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
up → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
v → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
w → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
x → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
y → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter
z → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

no setter

Methods

char(String character) → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

Append a dynamic character atom (digits, punctuation, Unicode).
code(KeySelector keyCode) → KeySequence

Available on KeySequence, provided by the KeySequenceChain extension

Append a key identity held in a variable — a logical KeyCode or a physical KeyPosition.
isPrefixOf(KeySequence other) → bool
Whether every step of this sequence is a prefix of other — used to warn about remap conflicts where one binding delays another (e.g. g delays g g).
matches(KeyEvent event) → bool
Whether this sequence's first step matches event. Multi-step sequences have their continuation matched step-by-step by the InputDispatcher.
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

Static Methods

char(String character) → KeyCode
A printable-character key with no modifiers — the entry point for atoms outside the named statics (digits, punctuation, Unicode).
fromEvent(KeyEvent event) → KeySequence
This event's key and modifiers as a one-step sequence (see KeyEvent.toSequence).
fromEvents(List<KeyEvent> events) → KeySequence
A multi-step sequence from the events that produced it, one step per event, in order — used to render the prefix of a pending match.
parse(String source) → KeySequence
Parses a human-readable sequence such as ctrl+x ctrl+s, g g, super+k, or ?. Throws FormatException on malformed input; see tryParse for the non-throwing form. parse(x.hintLabel) == x for every sequence.
tryParse(String source) → KeySequence?
Parses a human-readable sequence, or returns null if source is not a valid one. See parse for the grammar.

Constants

a → const KeyCode
alt → const PendingKeySequence
b → const KeyCode
backspace → const KeyCode
c → const KeyCode
ctrl → const PendingKeySequence
d → const KeyCode
delete → const KeyCode
down → const KeyCode
e → const KeyCode
end → const KeyCode
enter → const KeyCode
escape → const KeyCode
f → const KeyCode
f1 → const KeyCode
f2 → const KeyCode
f3 → const KeyCode
f4 → const KeyCode
f5 → const KeyCode
f6 → const KeyCode
f7 → const KeyCode
f8 → const KeyCode
f9 → const KeyCode
f10 → const KeyCode
f11 → const KeyCode
f12 → const KeyCode
f13 → const KeyCode
f14 → const KeyCode
f15 → const KeyCode
f16 → const KeyCode
f17 → const KeyCode
f18 → const KeyCode
f19 → const KeyCode
f20 → const KeyCode
f21 → const KeyCode
f22 → const KeyCode
f23 → const KeyCode
f24 → const KeyCode
f25 → const KeyCode
f26 → const KeyCode
f27 → const KeyCode
f28 → const KeyCode
f29 → const KeyCode
f30 → const KeyCode
f31 → const KeyCode
f32 → const KeyCode
f33 → const KeyCode
f34 → const KeyCode
f35 → const KeyCode
g → const KeyCode
h → const KeyCode
home → const KeyCode
i → const KeyCode
insert → const KeyCode
j → const KeyCode
k → const KeyCode
l → const KeyCode
left → const KeyCode
m → const KeyCode
mediaPause → const KeyCode
mediaPlay → const KeyCode
mediaPlayPause → const KeyCode
mediaStop → const KeyCode
mediaTrackNext → const KeyCode
mediaTrackPrevious → const KeyCode
meta → const PendingKeySequence
n → const KeyCode
o → const KeyCode
p → const KeyCode
pageDown → const KeyCode
pageUp → const KeyCode
pause → const KeyCode
printScreen → const KeyCode
q → const KeyCode
r → const KeyCode
s → const KeyCode
shift → const PendingKeySequence
shiftTab → const KeySequence
Shift+Tab — the common back-traverse chord, spelled as a named atom because terminals encode it as one distinct sequence.
space → const KeyCode
superKey → const PendingKeySequence
t → const KeyCode
tab → const KeyCode
u → const KeyCode
up → const KeyCode
v → const KeyCode
volumeDown → const KeyCode
volumeMute → const KeyCode
volumeUp → const KeyCode
w → const KeyCode
x → const KeyCode
y → const KeyCode
z → const KeyCode