2020-06-05 06:49:36 +00:00
|
|
|
use bevy::{input::keyboard::KeyboardInput, prelude::*};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::build()
|
2020-11-03 03:01:17 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2020-12-16 05:57:16 +00:00
|
|
|
.add_system(print_keyboard_event_system.system())
|
2020-06-05 06:49:36 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct State {
|
|
|
|
event_reader: EventReader<KeyboardInput>,
|
|
|
|
}
|
|
|
|
|
2020-08-12 16:13:32 +00:00
|
|
|
/// This system prints out all keyboard events as they come in
|
2020-06-05 06:49:36 +00:00
|
|
|
fn print_keyboard_event_system(
|
2020-10-18 20:20:42 +00:00
|
|
|
mut state: Local<State>,
|
2020-06-05 06:49:36 +00:00
|
|
|
keyboard_input_events: Res<Events<KeyboardInput>>,
|
|
|
|
) {
|
|
|
|
for event in state.event_reader.iter(&keyboard_input_events) {
|
|
|
|
println!("{:?}", event);
|
|
|
|
}
|
|
|
|
}
|