docs/bevy/examples/input/keyboard_input_events.rs 480 B · 17 lines · raw · history

1 //! Prints out all keyboard events.
2
3 use bevy::{input::keyboard::KeyboardInput, prelude::*};
4
5 fn main() {
6 App::new()
7 .add_plugins(DefaultPlugins)
8 .add_systems(Update, print_keyboard_event_system)
9 .run();
10 }
11
12 /// This system prints out all keyboard inputs as they come in
13 fn print_keyboard_event_system(mut keyboard_inputs: MessageReader<KeyboardInput>) {
14 for keyboard_input in keyboard_inputs.read() {
15 info!("{:?}", keyboard_input);
16 }
17 }