Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/src/keyboard/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ use crate::keyboard::{Key, Location, Modifiers};
pub enum Event {
/// A keyboard key was pressed.
KeyPressed {
/// The key pressed.
/// The key pressed. Tries to meet expectations, currently equal to `modified_key`.
key: Key,

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

/// The key on keyboard layer 0 pressed.
baselayer_key: Key,

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

Expand All @@ -33,12 +36,15 @@ pub enum Event {

/// A keyboard key was released.
KeyReleased {
/// The key released.
/// The key released. Tries to meet expectations, currently equal to `modified_key`.
key: Key,

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

/// The key on keyboard layer 0 released.
baselayer_key: Key,

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

Expand Down
6 changes: 4 additions & 2 deletions test/src/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ pub fn press_key(

Event::Keyboard(keyboard::Event::KeyPressed {
key: key.clone(),
modified_key: key,
modified_key: key.clone(),
baselayer_key: key,
physical_key: keyboard::key::Physical::Unidentified(
keyboard::key::NativeCode::Unidentified,
),
Expand All @@ -391,7 +392,8 @@ pub fn release_key(key: impl Into<keyboard::Key>) -> Event {

Event::Keyboard(keyboard::Event::KeyReleased {
key: key.clone(),
modified_key: key,
modified_key: key.clone(),
baselayer_key: key,
physical_key: keyboard::key::Physical::Unidentified(
keyboard::key::NativeCode::Unidentified,
),
Expand Down
7 changes: 5 additions & 2 deletions winit/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub fn window_event(
// Ignore keyboard presses/releases during window focus/unfocus
WindowEvent::KeyboardInput { is_synthetic, .. } if is_synthetic => None,
WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
let key = {
let baselayer_key = {
#[cfg(not(target_arch = "wasm32"))]
{
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
Expand Down Expand Up @@ -242,8 +242,9 @@ pub fn window_event(
..
} = event;

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

Expand All @@ -265,6 +266,7 @@ pub fn window_event(
keyboard::Event::KeyPressed {
key,
modified_key,
baselayer_key,
physical_key,
modifiers,
location,
Expand All @@ -275,6 +277,7 @@ pub fn window_event(
keyboard::Event::KeyReleased {
key,
modified_key,
baselayer_key,
physical_key,
modifiers,
location,
Expand Down