bevy/examples/input/keyboard_input_events.rs
Nathan Stocks 9871e7e24b
Remove add_default_plugins and add MinimalPlugins for simple "headless" scenarios (#767)
Remove add_default_plugins and add MinimalPlugins for simple "headless" scenarios
2020-11-02 18:38:37 -08:00

24 lines
579 B
Rust

use bevy::{input::keyboard::KeyboardInput, prelude::*};
fn main() {
App::build()
.add_plugin_group(DefaultPlugins)
.add_system(print_keyboard_event_system.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);
}
}