Keybind Plugin
A Bevy plugin that maps physical inputs — keyboard keys, mouse buttons, gamepad axes, touch — to named actions. Game code listens to actions, not hardware; rebinding is a runtime change with no game logic involved.
- Rust
- Bevy
- ECS
Action-Based Binding
Inputs are stored in a KeyBindings resource as a map from action name to a list of InputType values. One action can be triggered by multiple inputs simultaneously —
"zoom_in" could be bound to both scroll wheel up and the + key without any special-casing. The plugin reads all registered
bindings each frame and emits a MessageEvent for any action whose input is active.
Input Types
The InputType enum covers every major input source Bevy exposes:
- Keyboard — any
KeyCode - MouseButton — left, right, middle, or extra buttons
- MouseWheel — up/down scroll delta
- MouseMotion — raw cursor delta for look/orbit
- GamepadButton — any button on any connected gamepad
- GamepadAxis — analogue stick or trigger with deadzone
- TouchInput — touch phase detection
Pressed / JustPressed / Released
Each action emits an ActionState alongside the action name: JustPressed fires once on the first frame the input is active, Pressed fires every frame it remains held, and JustReleased fires once when the input is lifted. This mirrors Bevy's own input
API so game systems can use familiar patterns without querying raw
hardware.
Orbit Camera
The keybind plugin is the default input provider for the Orbit Camera plugin. KeybindOrbitInput implements OrbitCameraInput by reading MessageEvents and translating them into camera deltas. Rebinding the camera
controls at runtime requires only updating the KeyBindings resource — neither the camera plugin nor the game loop need to know.