2022-05-16 13:53:20 +00:00
|
|
|
//! Prints out all chars as they are inputted.
|
|
|
|
|
2024-04-30 00:49:41 +00:00
|
|
|
use bevy::{
|
|
|
|
input::{
|
|
|
|
keyboard::{Key, KeyboardInput},
|
|
|
|
ButtonState,
|
|
|
|
},
|
|
|
|
prelude::*,
|
|
|
|
};
|
2020-11-07 01:15:56 +00:00
|
|
|
|
|
|
|
fn main() {
|
2021-07-27 20:21:06 +00:00
|
|
|
App::new()
|
2020-11-07 01:15:56 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2023-03-18 01:45:34 +00:00
|
|
|
.add_systems(Update, print_char_event_system)
|
2020-11-07 01:15:56 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This system prints out all char events as they come in
|
2024-04-30 00:49:41 +00:00
|
|
|
fn print_char_event_system(mut char_input_events: EventReader<KeyboardInput>) {
|
2023-08-30 14:20:03 +00:00
|
|
|
for event in char_input_events.read() {
|
2024-04-30 00:49:41 +00:00
|
|
|
// Only check for characters when the key is pressed
|
|
|
|
if event.state == ButtonState::Released {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if let Key::Character(character) = &event.logical_key {
|
|
|
|
info!("{:?}: '{}'", event, character);
|
|
|
|
}
|
2020-11-07 01:15:56 +00:00
|
|
|
}
|
|
|
|
}
|