Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
bevy-input-sequence
This crate recognizes input sequences and sends events.
Use cases
- Hotkeys
- Cheat codes
- Developer UI
Installation
Usage
Import symbols
use *;
use *;
Define an event
;
Add event as an input_sequence
Add a key sequence component
So long as one component is present, it will fire one event when the input
sequence is entered. This crate re-exports the keyseq!
macro for bevy from the keyseq crate.
Examples
keycode
The keycode
example recognizes the key sequences W D S A
and W A S D
and
fires a distinct event.
keymod
The keymod
example recognizes ctrl-W ctrl-D ctrl-S ctrl-A
and fires an event.
gamepad_button
The gamepad_button
example recognizes gamepad buttons North East South West
or Y B A X
on an Xbox controller and fires an event.
multiple_input
The multiple_input
example recognizes gamepad buttons North East South West
,
or Y B A X
on an Xbox controller, or W D S A
on a keyboard and fires an
event.
Note: Either W D S A
will be recognized from the keyboard, or Y B A X
will
be recognized from the controller. But a mixed sequence like W D A X
will not
currently be recognized. If this should be done and how exactly one should do it
are under consideration. Please open an issue or PR if you have thoughts on this.
run_if
The run_if
example recognizes Space
and fires an event if it's in game mode.
The Escape
key toggles the app betwee n menu and game mode.
Advanced Usage
Add an event with a condition
Some key sequences you may only what to fire in particular modes. You can supply
a condition that will only run if it's met. This works nicely with bevy States
for example.
See the "run_if" example for more details.
Add a input sequence component with a time limit
Input sequences can have time limits. Sequences must be completed within the time limit in order to fire the event.
Compatibility
bevy-input-sequence | bevy |
---|---|
0.1.0 | 0.11 |
0.2.0 | 0.12 |
N/A | 0.13 |
License
This crate is licensed under the MIT License or the Apache License 2.0.