Add modified_key to keyboard::Event
This commit is contained in:
parent
cbe91d4a7c
commit
94c8b9639c
2 changed files with 10 additions and 3 deletions
|
|
@ -15,6 +15,9 @@ pub enum Event {
|
||||||
/// The key pressed.
|
/// The key pressed.
|
||||||
key: Key,
|
key: Key,
|
||||||
|
|
||||||
|
/// The key pressed with all keyboard modifiers applied, except Ctrl.
|
||||||
|
modified_key: Key,
|
||||||
|
|
||||||
/// The physical key pressed.
|
/// The physical key pressed.
|
||||||
physical_key: key::Physical,
|
physical_key: key::Physical,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ pub fn window_event(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
|
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
|
||||||
let logical_key = {
|
let key = {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
{
|
{
|
||||||
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
|
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
|
||||||
|
|
@ -202,7 +202,7 @@ pub fn window_event(
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
{
|
{
|
||||||
// TODO: Fix inconsistent API on Wasm
|
// TODO: Fix inconsistent API on Wasm
|
||||||
event.logical_key
|
event.logical_key.clone()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -225,10 +225,13 @@ pub fn window_event(
|
||||||
let winit::event::KeyEvent {
|
let winit::event::KeyEvent {
|
||||||
state,
|
state,
|
||||||
location,
|
location,
|
||||||
|
logical_key,
|
||||||
physical_key,
|
physical_key,
|
||||||
..
|
..
|
||||||
} = event;
|
} = 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 physical_key = self::physical_key(physical_key);
|
||||||
let modifiers = self::modifiers(modifiers);
|
let modifiers = self::modifiers(modifiers);
|
||||||
|
|
||||||
|
|
@ -249,6 +252,7 @@ pub fn window_event(
|
||||||
winit::event::ElementState::Pressed => {
|
winit::event::ElementState::Pressed => {
|
||||||
keyboard::Event::KeyPressed {
|
keyboard::Event::KeyPressed {
|
||||||
key,
|
key,
|
||||||
|
modified_key,
|
||||||
physical_key,
|
physical_key,
|
||||||
modifiers,
|
modifiers,
|
||||||
location,
|
location,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue