Align NamedKey and KeyCode more closely with the W3C specs (#4018)
By removing `NamedKey::Space` and rename "super" key to "meta".
- `NamedKey::Space` is not in the spec, and doesn't make sense to
special-case. We use `Key::Character("")` instead..
I've added an extra check on the Windows backend, to ensure that the code
functionally works the same before and after. Whether that check is
desirable or not can be figured out later.
- "super" is inconsistent with the W3C spec, and while it's arguably not the
best name, it's worse that Winit is diverging and choosing a different name.
List of renamings:
- `KeyCode::SuperLeft` -> `KeyCode::MetaLeft`
- `KeyCode::SuperRight` -> `KeyCode::MetaRight`
- `KeyCode::Meta` -> `KeyCode::Super`
- `NamedKey::Meta` -> `NamedKey::Super`
- `NamedKey::Super` -> `NamedKey::Meta`
- `ModifiersState::SUPER` -> `ModifiersState::META` (deprecated)
- `ModifiersState::super_key` -> `ModifiersState::meta_key`
- `ModifiersKeys::LSUPER` -> `ModifiersKeys::LMETA`
- `ModifiersKeys::RSUPER` -> `ModifiersKeys::RMETA`
This commit is contained in:
parent
7e13248be3
commit
cdbdd974fb
14 changed files with 118 additions and 97 deletions
|
|
@ -184,7 +184,6 @@ pub fn key_text(event: &KeyboardEvent) -> Option<SmolStr> {
|
|||
Key::Character(text) => Some(text.clone()),
|
||||
Key::Named(NamedKey::Tab) => Some(SmolStr::new("\t")),
|
||||
Key::Named(NamedKey::Enter) => Some(SmolStr::new("\r")),
|
||||
Key::Named(NamedKey::Space) => Some(SmolStr::new(" ")),
|
||||
_ => None,
|
||||
}
|
||||
.map(SmolStr::new)
|
||||
|
|
@ -216,7 +215,7 @@ pub fn keyboard_modifiers(event: &KeyboardEvent) -> ModifiersState {
|
|||
state |= ModifiersState::ALT;
|
||||
}
|
||||
if event.meta_key() {
|
||||
state |= ModifiersState::SUPER;
|
||||
state |= ModifiersState::META;
|
||||
}
|
||||
|
||||
state
|
||||
|
|
@ -235,7 +234,7 @@ pub fn mouse_modifiers(event: &MouseEvent) -> ModifiersState {
|
|||
state |= ModifiersState::ALT;
|
||||
}
|
||||
if event.meta_key() {
|
||||
state |= ModifiersState::SUPER;
|
||||
state |= ModifiersState::META;
|
||||
}
|
||||
|
||||
state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue