Keyboard class final

The surface's keyboard: what it guarantees, and what is held right now.

Obtained from the tree, but deliberately not a widget — continuous input is a state question, sampled from the ticker you already have, not a callback:

late final _keyboard = Keyboard.of(context);   // safe to cache

void _tick(Duration elapsed) {
  final keys = _keyboard.snapshot;             // stable for this tick
  if (keys.isHeld(KeyPosition.w)) ship.thrust(dt);
  if (keys.wasPressed(KeyCode.space)) ship.fire();
}

Edges (wasPressed/wasReleased) live for exactly one latch, and while a ticker is running the tick IS the latch — so a tap survives whatever else the app renders between the press and this callback. With no ticker registered the snapshot advances once per rendered frame instead, so a ticker-free app never reports a stale tap forever (RFC 0020 §5.6).

Reactivity is asymmetric, by design. Obtaining the handle registers a dependency on changes to what the keyboard IS — capabilities, session identity, and newly learned layout caps — so a control scheme branched on capabilities rebuilds when a terminal finishes negotiating, and a hint bar re-renders when a position's real cap becomes known. Key transitions never notify: an API that cannot notify on input cannot cause an input-rate rebuild storm (RFC 0020 §15, §19). Layout learning is bounded by the physical key count, not the keystroke rate.

Properties

capabilities → KeyboardCapabilities
What this surface has been confirmed to guarantee. Legal to read in build(); reading it there is what subscribes the widget to negotiation and reconnect.
no setter
hashCode → int
The hash code for this object.
no setterinherited
layout → KeyboardLayout
What this keyboard's keys are capped with, for rendering a positional control honestly (RFC 0020 §9).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
snapshot → KeyboardSnapshot
The frame-latched view of what is held (RFC 0020 §5.6): immutable for the whole frame, so every read within one tick agrees.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

nextKey(BuildContext context) → Future<KeyEvent?>
Awaits exactly one key press — the rebind row, the press-any-key prompt, vim's getchar() for m<letter> and quoted-insert.
of(BuildContext context) → Keyboard
The keyboard of the surface context is mounted on.