mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Map glutin modifier keycodes to servo keycodes.
This commit is contained in:
parent
1f5b0008ac
commit
7ef8b0fd5d
1 changed files with 19 additions and 10 deletions
|
@ -243,16 +243,16 @@ impl Window {
|
|||
VirtualKeyCode::RAlt => self.toggle_modifier(RIGHT_ALT),
|
||||
VirtualKeyCode::LWin => self.toggle_modifier(LEFT_SUPER),
|
||||
VirtualKeyCode::RWin => self.toggle_modifier(RIGHT_SUPER),
|
||||
_ => {
|
||||
if let Ok(key) = Window::glutin_key_to_script_key(virtual_key_code) {
|
||||
let state = match element_state {
|
||||
ElementState::Pressed => KeyState::Pressed,
|
||||
ElementState::Released => KeyState::Released,
|
||||
};
|
||||
let modifiers = Window::glutin_mods_to_script_mods(self.key_modifiers.get());
|
||||
self.event_queue.borrow_mut().push(WindowEvent::KeyEvent(key, state, modifiers));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if let Ok(key) = Window::glutin_key_to_script_key(virtual_key_code) {
|
||||
let state = match element_state {
|
||||
ElementState::Pressed => KeyState::Pressed,
|
||||
ElementState::Released => KeyState::Released,
|
||||
};
|
||||
let modifiers = Window::glutin_mods_to_script_mods(self.key_modifiers.get());
|
||||
self.event_queue.borrow_mut().push(WindowEvent::KeyEvent(key, state, modifiers));
|
||||
}
|
||||
}
|
||||
Event::KeyboardInput(_, _, None) => {
|
||||
|
@ -548,6 +548,15 @@ impl Window {
|
|||
VirtualKeyCode::Right => Ok(Key::Right),
|
||||
VirtualKeyCode::Down => Ok(Key::Down),
|
||||
|
||||
VirtualKeyCode::LShift => Ok(Key::LeftShift),
|
||||
VirtualKeyCode::LControl => Ok(Key::LeftControl),
|
||||
VirtualKeyCode::LAlt => Ok(Key::LeftAlt),
|
||||
VirtualKeyCode::LWin => Ok(Key::LeftSuper),
|
||||
VirtualKeyCode::RShift => Ok(Key::RightShift),
|
||||
VirtualKeyCode::RControl => Ok(Key::RightControl),
|
||||
VirtualKeyCode::RAlt => Ok(Key::RightAlt),
|
||||
VirtualKeyCode::RWin => Ok(Key::RightSuper),
|
||||
|
||||
VirtualKeyCode::Apostrophe => Ok(Key::Apostrophe),
|
||||
VirtualKeyCode::Backslash => Ok(Key::Backslash),
|
||||
VirtualKeyCode::Comma => Ok(Key::Comma),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue