mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
c3a72e9dc8
This PR adds a small example that shows how to use Keyboard modifiers, as shown in [this](https://github.com/bevyengine/bevy/issues/1654#issuecomment-798966921) snippet. Fixes #1656. Co-authored-by: guimcaballero <guim.caballero@gmail.com>
21 lines
604 B
Rust
21 lines
604 B
Rust
use bevy::{
|
|
input::{keyboard::KeyCode, Input},
|
|
prelude::*,
|
|
};
|
|
|
|
fn main() {
|
|
App::build()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_system(keyboard_input_system.system())
|
|
.run();
|
|
}
|
|
|
|
/// This system prints when Ctrl + Shift + A is pressed
|
|
fn keyboard_input_system(input: Res<Input<KeyCode>>) {
|
|
let shift = input.pressed(KeyCode::LShift) || input.pressed(KeyCode::RShift);
|
|
let ctrl = input.pressed(KeyCode::LControl) || input.pressed(KeyCode::RControl);
|
|
|
|
if ctrl && shift && input.just_pressed(KeyCode::A) {
|
|
println!("Just pressed Ctrl + Shift + A!");
|
|
}
|
|
}
|