Skip to content

Commit

Permalink
Add modified_key to keyboard::Event
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Sep 13, 2024
1 parent cbe91d4 commit bd8a49f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/src/keyboard/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub enum Event {
/// The key pressed.
key: Key,

/// The key pressed with all keyboard modifiers applied, except Ctrl.
modified_key: Key,

/// The physical key pressed.
physical_key: key::Physical,

Expand Down
8 changes: 6 additions & 2 deletions winit/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn window_event(
}
},
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
let logical_key = {
let key = {
#[cfg(not(target_arch = "wasm32"))]
{
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
Expand Down Expand Up @@ -225,10 +225,13 @@ pub fn window_event(
let winit::event::KeyEvent {
state,
location,
logical_key,

Check failure on line 228 in winit/src/conversion.rs

View workflow job for this annotation

GitHub Actions / wasm

use of moved value: `event.logical_key`

Check failure on line 228 in winit/src/conversion.rs

View workflow job for this annotation

GitHub Actions / wasm

use of moved value: `event.logical_key`
physical_key,
..
} = event;
let key = key(logical_key);

let key = self::key(key);
let modified_key = self::key(logical_key);
let physical_key = self::physical_key(physical_key);
let modifiers = self::modifiers(modifiers);

Expand All @@ -249,6 +252,7 @@ pub fn window_event(
winit::event::ElementState::Pressed => {
keyboard::Event::KeyPressed {
key,
modified_key,
physical_key,
modifiers,
location,
Expand Down

0 comments on commit bd8a49f

Please sign in to comment.