File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,10 @@ path = "examples/input/gamepad_input_events.rs"
302302name = " keyboard_input"
303303path = " examples/input/keyboard_input.rs"
304304
305+ [[example ]]
306+ name = " keyboard_modifiers"
307+ path = " examples/input/keyboard_modifiers.rs"
308+
305309[[example ]]
306310name = " keyboard_input_events"
307311path = " examples/input/keyboard_input_events.rs"
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ Example | File | Description
163163` gamepad_input_events ` | [ ` input/gamepad_input_events.rs ` ] ( ./input/gamepad_input_events.rs ) | Iterates and prints gamepad input and connection events
164164` keyboard_input ` | [ ` input/keyboard_input.rs ` ] ( ./input/keyboard_input.rs ) | Demonstrates handling a key press/release
165165` keyboard_input_events ` | [ ` input/keyboard_input_events.rs ` ] ( ./input/keyboard_input_events.rs ) | Prints out all keyboard events
166+ ` keyboard_modifiers ` | [ ` input/keyboard_modifiers.rs ` ] ( ./input/keyboard_modifiers.rs ) | Demonstrates using key modifiers (ctrl, shift)
166167` mouse_input ` | [ ` input/mouse_input.rs ` ] ( ./input/mouse_input.rs ) | Demonstrates handling a mouse button press/release
167168` mouse_input_events ` | [ ` input/mouse_input_events.rs ` ] ( ./input/mouse_input_events.rs ) | Prints out all mouse events (buttons, movement, etc.)
168169` touch_input ` | [ ` input/touch_input.rs ` ] ( ./input/touch_input.rs ) | Displays touch presses, releases, and cancels
Original file line number Diff line number Diff line change 1+ use bevy:: {
2+ input:: { keyboard:: KeyCode , Input } ,
3+ prelude:: * ,
4+ } ;
5+
6+ fn main ( ) {
7+ App :: build ( )
8+ . add_plugins ( DefaultPlugins )
9+ . add_system ( keyboard_input_system. system ( ) )
10+ . run ( ) ;
11+ }
12+
13+ /// This system prints when Ctrl + Shift + A is pressed
14+ fn keyboard_input_system ( input : Res < Input < KeyCode > > ) {
15+ let shift = input. pressed ( KeyCode :: LShift ) || input. pressed ( KeyCode :: RShift ) ;
16+ let ctrl = input. pressed ( KeyCode :: LControl ) || input. pressed ( KeyCode :: RControl ) ;
17+
18+ if ctrl && shift && input. just_pressed ( KeyCode :: A ) {
19+ println ! ( "Just pressed Ctrl + Shift + A!" ) ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments