bevy/examples/input/keyboard_input_events.rs
Carter Anderson 3a6f6de277
System Inputs, Outputs, Chaining, and Registration Ergo (#876)
System Inputs, Outputs, Chaining, and Registration Ergo
2020-11-16 18:18:00 -08:00

23 lines
565 B
Rust

use bevy::{input::keyboard::KeyboardInput, prelude::*};
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_system(print_keyboard_event_system)
.run();
}
#[derive(Default)]
struct State {
event_reader: EventReader<KeyboardInput>,
}
/// This system prints out all keyboard events as they come in
fn print_keyboard_event_system(
mut state: Local<State>,
keyboard_input_events: Res<Events<KeyboardInput>>,
) {
for event in state.event_reader.iter(&keyboard_input_events) {
println!("{:?}", event);
}
}