| Crates.io | rx_bevy_observable_keyboard |
| lib.rs | rx_bevy_observable_keyboard |
| version | 0.3.1 |
| created_at | 2026-01-19 07:03:37.481687+00 |
| updated_at | 2026-01-24 17:58:14.007393+00 |
| description | rx_bevy keyboard observable |
| homepage | https://github.com/AlexAegis/rx_bevy |
| repository | https://github.com/AlexAegis/rx_bevy |
| max_upload_size | |
| id | 2053886 |
| size | 136,709 |
The KeyboardObservable turns Bevy keyboard input events into signals. The
events are sourced from the ButtonInput<KeyCode> resource.
KeyCode signals can be observed in multiple modes:
KeyboardObservableEmit::JustPressed - emits once when the key is pressed down.KeyboardObservableEmit::JustReleased - emits once when the key is released.KeyboardObservableEmit::WhilePressed - emits continuously while the key is held down.MessageWriter.cargo run -p rx_bevy --example observable_keyboard_example
fn main() -> AppExit {
App::new()
.add_plugins((
DefaultPlugins,
RxPlugin,
RxSchedulerPlugin::<Update, Virtual>::default(),
))
.add_systems(Startup, setup)
.add_systems(
Update,
(
send_message(AppExit::Success).run_if(input_just_pressed(KeyCode::Escape)),
unsubscribe.run_if(input_just_pressed(KeyCode::Space)),
),
)
.run()
}
fn unsubscribe(mut example_entities: ResMut<MySubscriptions>) {
example_entities.subscription.unsubscribe();
}
#[derive(Resource)]
struct MySubscriptions {
subscription: SharedSubscription,
}
fn setup(mut commands: Commands, rx_schedule_update_virtual: RxSchedule<Update, Virtual>) {
let subscription = KeyboardObservable::new(default(), rx_schedule_update_virtual.handle())
.subscribe(PrintObserver::new("keyboard"));
commands.insert_resource(MySubscriptions {
subscription: SharedSubscription::new(subscription),
});
}
Output when pressing WASD keys and Space:
keyboard - next: KeyW
keyboard - next: KeyA
keyboard - next: KeyS
keyboard - next: KeyD
keyboard - next: Space
keyboard - unsubscribed