bevy/crates/bevy_input/src/system.rs
Michael Dorst 8aff7262d6 Fix doc_markdown lints in bevy_input (#3475)
#3457 adds the `doc_markdown` clippy lint, which checks doc comments to make sure code identifiers are escaped with backticks. This causes a lot of lint errors, so this is one of a number of PR's that will fix those lint errors one crate at a time.

This PR fixes lints in the `bevy_input` crate.
2021-12-29 17:38:10 +00:00

21 lines
612 B
Rust

use crate::{
keyboard::{KeyCode, KeyboardInput},
ElementState,
};
use bevy_app::AppExit;
use bevy_ecs::prelude::{EventReader, EventWriter};
/// Sends the `AppExit` event whenever the "esc" key is pressed.
pub fn exit_on_esc_system(
mut keyboard_input_events: EventReader<KeyboardInput>,
mut app_exit_events: EventWriter<AppExit>,
) {
for event in keyboard_input_events.iter() {
if let Some(key_code) = event.key_code {
if event.state == ElementState::Pressed && key_code == KeyCode::Escape {
app_exit_events.send(AppExit);
}
}
}
}