mirror of
https://github.com/bevyengine/bevy.git
synced 2026-05-06 06:06:42 -04:00
4d74baf1ae
This renames the concept of `BufferedEvent` to `Message`, and updates our APIs, comments, and documentation to refer to these types as "messages" instead of "events". It also removes/updates anything that considers messages to be "observable", "listenable", or "triggerable". This is a followup to https://github.com/bevyengine/bevy/pull/20731, which omitted the `BufferedEvent -> Message` rename for brevity. See that post for rationale.
27 lines
708 B
Rust
27 lines
708 B
Rust
//! Prints out all chars as they are inputted.
|
|
|
|
use bevy::{
|
|
input::keyboard::{Key, KeyboardInput},
|
|
prelude::*,
|
|
};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Update, print_char_event_system)
|
|
.run();
|
|
}
|
|
|
|
/// This system prints out all char events as they come in.
|
|
fn print_char_event_system(mut keyboard_inputs: MessageReader<KeyboardInput>) {
|
|
for event in keyboard_inputs.read() {
|
|
// Only check for characters when the key is pressed.
|
|
if !event.state.is_pressed() {
|
|
continue;
|
|
}
|
|
if let Key::Character(character) = &event.logical_key {
|
|
info!("{:?}: '{}'", event, character);
|
|
}
|
|
}
|
|
}
|