InputKey class sealed
One thing a human can hold down: a key on the keyboard, a button on the mouse, or a button on a gamepad.
Why sealed, and why every value is a static const
Both properties exist to make the declaration site read the way the owner specified:
triggerSkill = input.has<bool>(const TriggerBinding(.spacebar));
movement = input.has<Vector2>(const Vec2Binding(up: .w, down: .s, left: .a, right: .d));
.spacebar is Dart's dot shorthand: it resolves against the context
type, which is InputKey, so every key has to be reachable as a static
member of this class. And a binding is a const value type (see
InputBinding), which means the keys it holds must be const too. Every
constructor is private, so the declared values below are the only ones a
caller can name - with one deliberate exception, GamepadKey.call, which
builds a key for a player slot known at runtime and is therefore the one
place == rather than identical is doing the work.
id is a build-local bit index, not a wire format
id is this key's bit position in the raw device-state block (see
InputState), assigned by hand below and checked by
game_input_test.dart. It is deliberately not what serialization uses:
both isolate copies run the same build so they always agree on ids, but a
saved keybinding file outlives the build it was written by. So toJson
writes name and inserting a new key in the middle of the table below
costs nothing but a recompile.
Devices are additive
Gamepads landed exactly as this doc predicted they would: a GamepadKey
subclass, its values appended to all after the mouse buttons. No
existing id moved, no binding type changed, and InputBinding.isActuated
still asks nothing but "is this key down". Analog axes remain a
different shape (they are not a held/not-held bit); the sticks reach this
vocabulary through a deadzone rather than by being modelled honestly -
see GamepadButton.
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → int
-
Bit position in the raw device-state block. Stable within one build,
meaningless across builds - see the class doc.
final
- kind → String
-
Which device this key belongs to - the JSON discriminator, and what
fromJson switches on.
no setter
- name → String
-
The identifier this key is spelled with in Dart (
InputKey.arrowLeft) and in JSON. The two are the same string on purpose: a keybinding file is readable, and a typo in one is greppable against the other.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object?> -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
Two keys are the same key when they occupy the same bit.
override
Static Properties
Constants
- a → const InputKey
- altLeft → const InputKey
- altRight → const InputKey
- arrowDown → const InputKey
- arrowLeft → const InputKey
- arrowRight → const InputKey
- arrowUp → const InputKey
- b → const InputKey
- backMouseButton → const InputKey
- backquote → const InputKey
- backslash → const InputKey
- backspace → const InputKey
- bracketLeft → const InputKey
- bracketRight → const InputKey
- c → const InputKey
- capsLock → const InputKey
- comma → const InputKey
- controlLeft → const InputKey
- controlRight → const InputKey
- d → const InputKey
- delete → const InputKey
- digit0 → const InputKey
- digit1 → const InputKey
- digit2 → const InputKey
- digit3 → const InputKey
- digit4 → const InputKey
- digit5 → const InputKey
- digit6 → const InputKey
- digit7 → const InputKey
- digit8 → const InputKey
- digit9 → const InputKey
- e → const InputKey
- end → const InputKey
- enter → const InputKey
- equal → const InputKey
- escape → const InputKey
- f → const InputKey
- f1 → const InputKey
- f2 → const InputKey
- f3 → const InputKey
- f4 → const InputKey
- f5 → const InputKey
- f6 → const InputKey
- f7 → const InputKey
- f8 → const InputKey
- f9 → const InputKey
- f10 → const InputKey
- f11 → const InputKey
- f12 → const InputKey
- forwardMouseButton → const InputKey
- g → const InputKey
- h → const InputKey
- home → const InputKey
- i → const InputKey
- insert → const InputKey
- j → const InputKey
- k → const InputKey
- l → const InputKey
- leftMouseButton → const InputKey
- m → const InputKey
- metaLeft → const InputKey
- metaRight → const InputKey
- middleMouseButton → const InputKey
- minus → const InputKey
- n → const InputKey
- numpad0 → const InputKey
- numpad1 → const InputKey
- numpad2 → const InputKey
- numpad3 → const InputKey
- numpad4 → const InputKey
- numpad5 → const InputKey
- numpad6 → const InputKey
- numpad7 → const InputKey
- numpad8 → const InputKey
- numpad9 → const InputKey
- numpadAdd → const InputKey
- numpadDecimal → const InputKey
- numpadDivide → const InputKey
- numpadEnter → const InputKey
- numpadMultiply → const InputKey
- numpadSubtract → const InputKey
- o → const InputKey
- p → const InputKey
- padA → const GamepadKey
- padB → const GamepadKey
- padDown → const GamepadKey
- padHome → const GamepadKey
- padLeft → const GamepadKey
- padLeftShoulder → const GamepadKey
- padLeftStick → const GamepadKey
- padLeftStickDown → const GamepadKey
- padLeftStickLeft → const GamepadKey
- padLeftStickRight → const GamepadKey
- padLeftStickUp → const GamepadKey
- padLeftTrigger → const GamepadKey
- padRight → const GamepadKey
- padRightShoulder → const GamepadKey
- padRightStick → const GamepadKey
- padRightStickDown → const GamepadKey
- padRightStickLeft → const GamepadKey
- padRightStickRight → const GamepadKey
- padRightStickUp → const GamepadKey
- padRightTrigger → const GamepadKey
- padSelect → const GamepadKey
- padStart → const GamepadKey
- padTouchpad → const GamepadKey
- padUp → const GamepadKey
- padX → const GamepadKey
- padY → const GamepadKey
- pageDown → const InputKey
- pageUp → const InputKey
- period → const InputKey
- q → const InputKey
- quote → const InputKey
- r → const InputKey
- rightMouseButton → const InputKey
- s → const InputKey
- semicolon → const InputKey
- shiftLeft → const InputKey
- shiftRight → const InputKey
- slash → const InputKey
- spacebar → const InputKey
- t → const InputKey
- tab → const InputKey
- u → const InputKey
- v → const InputKey
- w → const InputKey
- x → const InputKey
- y → const InputKey
- z → const InputKey