2020-06-05 06:49:36 +00:00
|
|
|
use bevy::{
|
|
|
|
input::{keyboard::KeyCode, Input},
|
|
|
|
prelude::*,
|
|
|
|
};
|
2020-04-04 21:59:49 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::build()
|
2020-11-03 02:38:37 +00:00
|
|
|
.add_plugin_group(DefaultPlugins)
|
2020-06-05 06:55:12 +00:00
|
|
|
.add_system(keyboard_input_system.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) {
|
|
|
|
println!("'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) {
|
|
|
|
println!("'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) {
|
|
|
|
println!("'A' just released");
|
2020-04-30 20:52:11 +00:00
|
|
|
}
|
2020-04-04 21:59:49 +00:00
|
|
|
}
|