2022-05-16 13:53:20 +00:00
|
|
|
//! Demonstrates handling a key press/release.
|
|
|
|
|
2022-09-05 00:30:21 +00:00
|
|
|
use bevy::prelude::*;
|
2020-04-04 21:59:49 +00:00
|
|
|
|
|
|
|
fn main() {
|
2021-07-27 20:21:06 +00:00
|
|
|
App::new()
|
2020-11-03 03:01:17 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2021-07-27 23:42:36 +00:00
|
|
|
.add_system(keyboard_input_system)
|
2020-04-04 21:59:49 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2020-06-05 06:55:12 +00:00
|
|
|
/// This system prints 'A' key state
|
|
|
|
fn keyboard_input_system(keyboard_input: Res<Input<KeyCode>>) {
|
|
|
|
if keyboard_input.pressed(KeyCode::A) {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("'A' currently pressed");
|
2020-06-05 05:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 06:55:12 +00:00
|
|
|
if keyboard_input.just_pressed(KeyCode::A) {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("'A' just pressed");
|
2020-04-30 20:52:11 +00:00
|
|
|
}
|
2020-04-04 21:59:49 +00:00
|
|
|
|
2020-06-05 06:55:12 +00:00
|
|
|
if keyboard_input.just_released(KeyCode::A) {
|
2021-04-22 23:30:48 +00:00
|
|
|
info!("'A' just released");
|
2020-04-30 20:52:11 +00:00
|
|
|
}
|
2020-04-04 21:59:49 +00:00
|
|
|
}
|