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::{
|
2024-07-15 15:03:48 +00:00
|
|
|
input::keyboard::{Key, KeyboardInput},
|
2024-04-30 00:49:41 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2024-07-15 15:03:48 +00:00
|
|
|
/// 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-07-15 15:03:48 +00:00
|
|
|
// Only check for characters when the key is pressed.
|
|
|
|
if !event.state.is_pressed() {
|
2024-04-30 00:49:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if let Key::Character(character) = &event.logical_key {
|
|
|
|
info!("{:?}: '{}'", event, character);
|
|
|
|
}
|
2020-11-07 01:15:56 +00:00
|
|
|
}
|
|
|
|
}
|