Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 919 Bytes

closing_the_window_on_esc_pressed.md

File metadata and controls

25 lines (19 loc) · 919 Bytes

Closing The Window On Esc Pressed

There are build-in systems in Bevy that increase our convenience. For example, the system close_on_esc will close the window when the Esc key is pressed.

use bevy::{
    app::{App, Update},
    window::close_on_esc,
    DefaultPlugins,
};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Update, close_on_esc)
        .run();
}

The close_on_esc is added to the schedule Update, so that our App checks if the Esc key is pressed whenever the app is updated.

➡️ Next: Camera 2D

📘 Back: Table of contents