diff --git a/src/keyboard.rs b/src/keyboard.rs index 5dd99be9d4..a4390318d3 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -664,409 +664,6 @@ pub enum KeyCode { F35, } -impl KeyCode { - pub fn from_key_code_attribute_value(kcav: &str) -> Self { - match kcav { - "Backquote" => KeyCode::Backquote, - "Backslash" => KeyCode::Backslash, - "BracketLeft" => KeyCode::BracketLeft, - "BracketRight" => KeyCode::BracketRight, - "Comma" => KeyCode::Comma, - "Digit0" => KeyCode::Digit0, - "Digit1" => KeyCode::Digit1, - "Digit2" => KeyCode::Digit2, - "Digit3" => KeyCode::Digit3, - "Digit4" => KeyCode::Digit4, - "Digit5" => KeyCode::Digit5, - "Digit6" => KeyCode::Digit6, - "Digit7" => KeyCode::Digit7, - "Digit8" => KeyCode::Digit8, - "Digit9" => KeyCode::Digit9, - "Equal" => KeyCode::Equal, - "IntlBackslash" => KeyCode::IntlBackslash, - "IntlRo" => KeyCode::IntlRo, - "IntlYen" => KeyCode::IntlYen, - "KeyA" => KeyCode::KeyA, - "KeyB" => KeyCode::KeyB, - "KeyC" => KeyCode::KeyC, - "KeyD" => KeyCode::KeyD, - "KeyE" => KeyCode::KeyE, - "KeyF" => KeyCode::KeyF, - "KeyG" => KeyCode::KeyG, - "KeyH" => KeyCode::KeyH, - "KeyI" => KeyCode::KeyI, - "KeyJ" => KeyCode::KeyJ, - "KeyK" => KeyCode::KeyK, - "KeyL" => KeyCode::KeyL, - "KeyM" => KeyCode::KeyM, - "KeyN" => KeyCode::KeyN, - "KeyO" => KeyCode::KeyO, - "KeyP" => KeyCode::KeyP, - "KeyQ" => KeyCode::KeyQ, - "KeyR" => KeyCode::KeyR, - "KeyS" => KeyCode::KeyS, - "KeyT" => KeyCode::KeyT, - "KeyU" => KeyCode::KeyU, - "KeyV" => KeyCode::KeyV, - "KeyW" => KeyCode::KeyW, - "KeyX" => KeyCode::KeyX, - "KeyY" => KeyCode::KeyY, - "KeyZ" => KeyCode::KeyZ, - "Minus" => KeyCode::Minus, - "Period" => KeyCode::Period, - "Quote" => KeyCode::Quote, - "Semicolon" => KeyCode::Semicolon, - "Slash" => KeyCode::Slash, - "AltLeft" => KeyCode::AltLeft, - "AltRight" => KeyCode::AltRight, - "Backspace" => KeyCode::Backspace, - "CapsLock" => KeyCode::CapsLock, - "ContextMenu" => KeyCode::ContextMenu, - "ControlLeft" => KeyCode::ControlLeft, - "ControlRight" => KeyCode::ControlRight, - "Enter" => KeyCode::Enter, - "MetaLeft" => KeyCode::SuperLeft, - "MetaRight" => KeyCode::SuperRight, - "ShiftLeft" => KeyCode::ShiftLeft, - "ShiftRight" => KeyCode::ShiftRight, - " " => KeyCode::Space, - "Tab" => KeyCode::Tab, - "Convert" => KeyCode::Convert, - "KanaMode" => KeyCode::KanaMode, - "Lang1" => KeyCode::Lang1, - "Lang2" => KeyCode::Lang2, - "Lang3" => KeyCode::Lang3, - "Lang4" => KeyCode::Lang4, - "Lang5" => KeyCode::Lang5, - "NonConvert" => KeyCode::NonConvert, - "Delete" => KeyCode::Delete, - "End" => KeyCode::End, - "Help" => KeyCode::Help, - "Home" => KeyCode::Home, - "Insert" => KeyCode::Insert, - "PageDown" => KeyCode::PageDown, - "PageUp" => KeyCode::PageUp, - "ArrowDown" => KeyCode::ArrowDown, - "ArrowLeft" => KeyCode::ArrowLeft, - "ArrowRight" => KeyCode::ArrowRight, - "ArrowUp" => KeyCode::ArrowUp, - "NumLock" => KeyCode::NumLock, - "Numpad0" => KeyCode::Numpad0, - "Numpad1" => KeyCode::Numpad1, - "Numpad2" => KeyCode::Numpad2, - "Numpad3" => KeyCode::Numpad3, - "Numpad4" => KeyCode::Numpad4, - "Numpad5" => KeyCode::Numpad5, - "Numpad6" => KeyCode::Numpad6, - "Numpad7" => KeyCode::Numpad7, - "Numpad8" => KeyCode::Numpad8, - "Numpad9" => KeyCode::Numpad9, - "NumpadAdd" => KeyCode::NumpadAdd, - "NumpadBackspace" => KeyCode::NumpadBackspace, - "NumpadClear" => KeyCode::NumpadClear, - "NumpadClearEntry" => KeyCode::NumpadClearEntry, - "NumpadComma" => KeyCode::NumpadComma, - "NumpadDecimal" => KeyCode::NumpadDecimal, - "NumpadDivide" => KeyCode::NumpadDivide, - "NumpadEnter" => KeyCode::NumpadEnter, - "NumpadEqual" => KeyCode::NumpadEqual, - "NumpadHash" => KeyCode::NumpadHash, - "NumpadMemoryAdd" => KeyCode::NumpadMemoryAdd, - "NumpadMemoryClear" => KeyCode::NumpadMemoryClear, - "NumpadMemoryRecall" => KeyCode::NumpadMemoryRecall, - "NumpadMemoryStore" => KeyCode::NumpadMemoryStore, - "NumpadMemorySubtract" => KeyCode::NumpadMemorySubtract, - "NumpadMultiply" => KeyCode::NumpadMultiply, - "NumpadParenLeft" => KeyCode::NumpadParenLeft, - "NumpadParenRight" => KeyCode::NumpadParenRight, - "NumpadStar" => KeyCode::NumpadStar, - "NumpadSubtract" => KeyCode::NumpadSubtract, - "Escape" => KeyCode::Escape, - "Fn" => KeyCode::Fn, - "FnLock" => KeyCode::FnLock, - "PrintScreen" => KeyCode::PrintScreen, - "ScrollLock" => KeyCode::ScrollLock, - "Pause" => KeyCode::Pause, - "BrowserBack" => KeyCode::BrowserBack, - "BrowserFavorites" => KeyCode::BrowserFavorites, - "BrowserForward" => KeyCode::BrowserForward, - "BrowserHome" => KeyCode::BrowserHome, - "BrowserRefresh" => KeyCode::BrowserRefresh, - "BrowserSearch" => KeyCode::BrowserSearch, - "BrowserStop" => KeyCode::BrowserStop, - "Eject" => KeyCode::Eject, - "LaunchApp1" => KeyCode::LaunchApp1, - "LaunchApp2" => KeyCode::LaunchApp2, - "LaunchMail" => KeyCode::LaunchMail, - "MediaPlayPause" => KeyCode::MediaPlayPause, - "MediaSelect" => KeyCode::MediaSelect, - "MediaStop" => KeyCode::MediaStop, - "MediaTrackNext" => KeyCode::MediaTrackNext, - "MediaTrackPrevious" => KeyCode::MediaTrackPrevious, - "Power" => KeyCode::Power, - "Sleep" => KeyCode::Sleep, - "AudioVolumeDown" => KeyCode::AudioVolumeDown, - "AudioVolumeMute" => KeyCode::AudioVolumeMute, - "AudioVolumeUp" => KeyCode::AudioVolumeUp, - "WakeUp" => KeyCode::WakeUp, - "Hyper" => KeyCode::Hyper, - "Turbo" => KeyCode::Turbo, - "Abort" => KeyCode::Abort, - "Resume" => KeyCode::Resume, - "Suspend" => KeyCode::Suspend, - "Again" => KeyCode::Again, - "Copy" => KeyCode::Copy, - "Cut" => KeyCode::Cut, - "Find" => KeyCode::Find, - "Open" => KeyCode::Open, - "Paste" => KeyCode::Paste, - "Props" => KeyCode::Props, - "Select" => KeyCode::Select, - "Undo" => KeyCode::Undo, - "Hiragana" => KeyCode::Hiragana, - "Katakana" => KeyCode::Katakana, - "F1" => KeyCode::F1, - "F2" => KeyCode::F2, - "F3" => KeyCode::F3, - "F4" => KeyCode::F4, - "F5" => KeyCode::F5, - "F6" => KeyCode::F6, - "F7" => KeyCode::F7, - "F8" => KeyCode::F8, - "F9" => KeyCode::F9, - "F10" => KeyCode::F10, - "F11" => KeyCode::F11, - "F12" => KeyCode::F12, - "F13" => KeyCode::F13, - "F14" => KeyCode::F14, - "F15" => KeyCode::F15, - "F16" => KeyCode::F16, - "F17" => KeyCode::F17, - "F18" => KeyCode::F18, - "F19" => KeyCode::F19, - "F20" => KeyCode::F20, - "F21" => KeyCode::F21, - "F22" => KeyCode::F22, - "F23" => KeyCode::F23, - "F24" => KeyCode::F24, - "F25" => KeyCode::F25, - "F26" => KeyCode::F26, - "F27" => KeyCode::F27, - "F28" => KeyCode::F28, - "F29" => KeyCode::F29, - "F30" => KeyCode::F30, - "F31" => KeyCode::F31, - "F32" => KeyCode::F32, - "F33" => KeyCode::F33, - "F34" => KeyCode::F34, - "F35" => KeyCode::F35, - // TODO: Fix unbounded leak - string @ _ => KeyCode::Unidentified(NativeKeyCode::Web(Box::leak( - String::from(string).into_boxed_str(), - ))), - } - } - - pub fn to_key_code_attribute_value(&self) -> &'static str { - match self { - KeyCode::Unidentified(_) => "Unidentified", - KeyCode::Backquote => "Backquote", - KeyCode::Backslash => "Backslash", - KeyCode::BracketLeft => "BracketLeft", - KeyCode::BracketRight => "BracketRight", - KeyCode::Comma => "Comma", - KeyCode::Digit0 => "Digit0", - KeyCode::Digit1 => "Digit1", - KeyCode::Digit2 => "Digit2", - KeyCode::Digit3 => "Digit3", - KeyCode::Digit4 => "Digit4", - KeyCode::Digit5 => "Digit5", - KeyCode::Digit6 => "Digit6", - KeyCode::Digit7 => "Digit7", - KeyCode::Digit8 => "Digit8", - KeyCode::Digit9 => "Digit9", - KeyCode::Equal => "Equal", - KeyCode::IntlBackslash => "IntlBackslash", - KeyCode::IntlRo => "IntlRo", - KeyCode::IntlYen => "IntlYen", - KeyCode::KeyA => "KeyA", - KeyCode::KeyB => "KeyB", - KeyCode::KeyC => "KeyC", - KeyCode::KeyD => "KeyD", - KeyCode::KeyE => "KeyE", - KeyCode::KeyF => "KeyF", - KeyCode::KeyG => "KeyG", - KeyCode::KeyH => "KeyH", - KeyCode::KeyI => "KeyI", - KeyCode::KeyJ => "KeyJ", - KeyCode::KeyK => "KeyK", - KeyCode::KeyL => "KeyL", - KeyCode::KeyM => "KeyM", - KeyCode::KeyN => "KeyN", - KeyCode::KeyO => "KeyO", - KeyCode::KeyP => "KeyP", - KeyCode::KeyQ => "KeyQ", - KeyCode::KeyR => "KeyR", - KeyCode::KeyS => "KeyS", - KeyCode::KeyT => "KeyT", - KeyCode::KeyU => "KeyU", - KeyCode::KeyV => "KeyV", - KeyCode::KeyW => "KeyW", - KeyCode::KeyX => "KeyX", - KeyCode::KeyY => "KeyY", - KeyCode::KeyZ => "KeyZ", - KeyCode::Minus => "Minus", - KeyCode::Period => "Period", - KeyCode::Quote => "Quote", - KeyCode::Semicolon => "Semicolon", - KeyCode::Slash => "Slash", - KeyCode::AltLeft => "AltLeft", - KeyCode::AltRight => "AltRight", - KeyCode::Backspace => "Backspace", - KeyCode::CapsLock => "CapsLock", - KeyCode::ContextMenu => "ContextMenu", - KeyCode::ControlLeft => "ControlLeft", - KeyCode::ControlRight => "ControlRight", - KeyCode::Enter => "Enter", - KeyCode::SuperLeft => "MetaLeft", - KeyCode::SuperRight => "MetaRight", - KeyCode::ShiftLeft => "ShiftLeft", - KeyCode::ShiftRight => "ShiftRight", - KeyCode::Space => " ", - KeyCode::Tab => "Tab", - KeyCode::Convert => "Convert", - KeyCode::KanaMode => "KanaMode", - KeyCode::Lang1 => "Lang1", - KeyCode::Lang2 => "Lang2", - KeyCode::Lang3 => "Lang3", - KeyCode::Lang4 => "Lang4", - KeyCode::Lang5 => "Lang5", - KeyCode::NonConvert => "NonConvert", - KeyCode::Delete => "Delete", - KeyCode::End => "End", - KeyCode::Help => "Help", - KeyCode::Home => "Home", - KeyCode::Insert => "Insert", - KeyCode::PageDown => "PageDown", - KeyCode::PageUp => "PageUp", - KeyCode::ArrowDown => "ArrowDown", - KeyCode::ArrowLeft => "ArrowLeft", - KeyCode::ArrowRight => "ArrowRight", - KeyCode::ArrowUp => "ArrowUp", - KeyCode::NumLock => "NumLock", - KeyCode::Numpad0 => "Numpad0", - KeyCode::Numpad1 => "Numpad1", - KeyCode::Numpad2 => "Numpad2", - KeyCode::Numpad3 => "Numpad3", - KeyCode::Numpad4 => "Numpad4", - KeyCode::Numpad5 => "Numpad5", - KeyCode::Numpad6 => "Numpad6", - KeyCode::Numpad7 => "Numpad7", - KeyCode::Numpad8 => "Numpad8", - KeyCode::Numpad9 => "Numpad9", - KeyCode::NumpadAdd => "NumpadAdd", - KeyCode::NumpadBackspace => "NumpadBackspace", - KeyCode::NumpadClear => "NumpadClear", - KeyCode::NumpadClearEntry => "NumpadClearEntry", - KeyCode::NumpadComma => "NumpadComma", - KeyCode::NumpadDecimal => "NumpadDecimal", - KeyCode::NumpadDivide => "NumpadDivide", - KeyCode::NumpadEnter => "NumpadEnter", - KeyCode::NumpadEqual => "NumpadEqual", - KeyCode::NumpadHash => "NumpadHash", - KeyCode::NumpadMemoryAdd => "NumpadMemoryAdd", - KeyCode::NumpadMemoryClear => "NumpadMemoryClear", - KeyCode::NumpadMemoryRecall => "NumpadMemoryRecall", - KeyCode::NumpadMemoryStore => "NumpadMemoryStore", - KeyCode::NumpadMemorySubtract => "NumpadMemorySubtract", - KeyCode::NumpadMultiply => "NumpadMultiply", - KeyCode::NumpadParenLeft => "NumpadParenLeft", - KeyCode::NumpadParenRight => "NumpadParenRight", - KeyCode::NumpadStar => "NumpadStar", - KeyCode::NumpadSubtract => "NumpadSubtract", - KeyCode::Escape => "Escape", - KeyCode::Fn => "Fn", - KeyCode::FnLock => "FnLock", - KeyCode::PrintScreen => "PrintScreen", - KeyCode::ScrollLock => "ScrollLock", - KeyCode::Pause => "Pause", - KeyCode::BrowserBack => "BrowserBack", - KeyCode::BrowserFavorites => "BrowserFavorites", - KeyCode::BrowserForward => "BrowserForward", - KeyCode::BrowserHome => "BrowserHome", - KeyCode::BrowserRefresh => "BrowserRefresh", - KeyCode::BrowserSearch => "BrowserSearch", - KeyCode::BrowserStop => "BrowserStop", - KeyCode::Eject => "Eject", - KeyCode::LaunchApp1 => "LaunchApp1", - KeyCode::LaunchApp2 => "LaunchApp2", - KeyCode::LaunchMail => "LaunchMail", - KeyCode::MediaPlayPause => "MediaPlayPause", - KeyCode::MediaSelect => "MediaSelect", - KeyCode::MediaStop => "MediaStop", - KeyCode::MediaTrackNext => "MediaTrackNext", - KeyCode::MediaTrackPrevious => "MediaTrackPrevious", - KeyCode::Power => "Power", - KeyCode::Sleep => "Sleep", - KeyCode::AudioVolumeDown => "AudioVolumeDown", - KeyCode::AudioVolumeMute => "AudioVolumeMute", - KeyCode::AudioVolumeUp => "AudioVolumeUp", - KeyCode::WakeUp => "WakeUp", - KeyCode::Hyper => "Hyper", - KeyCode::Turbo => "Turbo", - KeyCode::Abort => "Abort", - KeyCode::Resume => "Resume", - KeyCode::Suspend => "Suspend", - KeyCode::Again => "Again", - KeyCode::Copy => "Copy", - KeyCode::Cut => "Cut", - KeyCode::Find => "Find", - KeyCode::Open => "Open", - KeyCode::Paste => "Paste", - KeyCode::Props => "Props", - KeyCode::Select => "Select", - KeyCode::Undo => "Undo", - KeyCode::Hiragana => "Hiragana", - KeyCode::Katakana => "Katakana", - KeyCode::F1 => "F1", - KeyCode::F2 => "F2", - KeyCode::F3 => "F3", - KeyCode::F4 => "F4", - KeyCode::F5 => "F5", - KeyCode::F6 => "F6", - KeyCode::F7 => "F7", - KeyCode::F8 => "F8", - KeyCode::F9 => "F9", - KeyCode::F10 => "F10", - KeyCode::F11 => "F11", - KeyCode::F12 => "F12", - KeyCode::F13 => "F13", - KeyCode::F14 => "F14", - KeyCode::F15 => "F15", - KeyCode::F16 => "F16", - KeyCode::F17 => "F17", - KeyCode::F18 => "F18", - KeyCode::F19 => "F19", - KeyCode::F20 => "F20", - KeyCode::F21 => "F21", - KeyCode::F22 => "F22", - KeyCode::F23 => "F23", - KeyCode::F24 => "F24", - KeyCode::F25 => "F25", - KeyCode::F26 => "F26", - KeyCode::F27 => "F27", - KeyCode::F28 => "F28", - KeyCode::F29 => "F29", - KeyCode::F30 => "F30", - KeyCode::F31 => "F31", - KeyCode::F32 => "F32", - KeyCode::F33 => "F33", - KeyCode::F34 => "F34", - KeyCode::F35 => "F35", - } - } -} - /// Key represents the meaning of a keypress. /// /// This mostly conforms to the UI Events Specification's [`KeyboardEvent.key`] with a few @@ -1801,635 +1398,6 @@ pub enum Key<'a> { F35, } -impl<'a> Key<'a> { - pub fn from_key_attribute_value(kav: &'a str) -> Self { - match kav { - // TODO: Report this in a better way. - "Unidentified" => Key::Unidentified(NativeKeyCode::Web("Unidentified")), - "Dead" => Key::Dead(None), - "Alt" => Key::Alt, - "AltGraph" => Key::AltGraph, - "CapsLock" => Key::CapsLock, - "Control" => Key::Control, - "Fn" => Key::Fn, - "FnLock" => Key::FnLock, - "NumLock" => Key::NumLock, - "ScrollLock" => Key::ScrollLock, - "Shift" => Key::Shift, - "Symbol" => Key::Symbol, - "SymbolLock" => Key::SymbolLock, - "Hyper" => Key::Hyper, - "Meta" => Key::Super, - "Enter" => Key::Enter, - "Tab" => Key::Tab, - "Space" => Key::Space, - "ArrowDown" => Key::ArrowDown, - "ArrowLeft" => Key::ArrowLeft, - "ArrowRight" => Key::ArrowRight, - "ArrowUp" => Key::ArrowUp, - "End" => Key::End, - "Home" => Key::Home, - "PageDown" => Key::PageDown, - "PageUp" => Key::PageUp, - "Backspace" => Key::Backspace, - "Clear" => Key::Clear, - "Copy" => Key::Copy, - "CrSel" => Key::CrSel, - "Cut" => Key::Cut, - "Delete" => Key::Delete, - "EraseEof" => Key::EraseEof, - "ExSel" => Key::ExSel, - "Insert" => Key::Insert, - "Paste" => Key::Paste, - "Redo" => Key::Redo, - "Undo" => Key::Undo, - "Accept" => Key::Accept, - "Again" => Key::Again, - "Attn" => Key::Attn, - "Cancel" => Key::Cancel, - "ContextMenu" => Key::ContextMenu, - "Escape" => Key::Escape, - "Execute" => Key::Execute, - "Find" => Key::Find, - "Help" => Key::Help, - "Pause" => Key::Pause, - "Play" => Key::Play, - "Props" => Key::Props, - "Select" => Key::Select, - "ZoomIn" => Key::ZoomIn, - "ZoomOut" => Key::ZoomOut, - "BrightnessDown" => Key::BrightnessDown, - "BrightnessUp" => Key::BrightnessUp, - "Eject" => Key::Eject, - "LogOff" => Key::LogOff, - "Power" => Key::Power, - "PowerOff" => Key::PowerOff, - "PrintScreen" => Key::PrintScreen, - "Hibernate" => Key::Hibernate, - "Standby" => Key::Standby, - "WakeUp" => Key::WakeUp, - "AllCandidates" => Key::AllCandidates, - "Alphanumeric" => Key::Alphanumeric, - "CodeInput" => Key::CodeInput, - "Compose" => Key::Compose, - "Convert" => Key::Convert, - "FinalMode" => Key::FinalMode, - "GroupFirst" => Key::GroupFirst, - "GroupLast" => Key::GroupLast, - "GroupNext" => Key::GroupNext, - "GroupPrevious" => Key::GroupPrevious, - "ModeChange" => Key::ModeChange, - "NextCandidate" => Key::NextCandidate, - "NonConvert" => Key::NonConvert, - "PreviousCandidate" => Key::PreviousCandidate, - "Process" => Key::Process, - "SingleCandidate" => Key::SingleCandidate, - "HangulMode" => Key::HangulMode, - "HanjaMode" => Key::HanjaMode, - "JunjaMode" => Key::JunjaMode, - "Eisu" => Key::Eisu, - "Hankaku" => Key::Hankaku, - "Hiragana" => Key::Hiragana, - "HiraganaKatakana" => Key::HiraganaKatakana, - "KanaMode" => Key::KanaMode, - "KanjiMode" => Key::KanjiMode, - "Katakana" => Key::Katakana, - "Romaji" => Key::Romaji, - "Zenkaku" => Key::Zenkaku, - "ZenkakuHankaku" => Key::ZenkakuHankaku, - "Soft1" => Key::Soft1, - "Soft2" => Key::Soft2, - "Soft3" => Key::Soft3, - "Soft4" => Key::Soft4, - "ChannelDown" => Key::ChannelDown, - "ChannelUp" => Key::ChannelUp, - "Close" => Key::Close, - "MailForward" => Key::MailForward, - "MailReply" => Key::MailReply, - "MailSend" => Key::MailSend, - "MediaClose" => Key::MediaClose, - "MediaFastForward" => Key::MediaFastForward, - "MediaPause" => Key::MediaPause, - "MediaPlay" => Key::MediaPlay, - "MediaPlayPause" => Key::MediaPlayPause, - "MediaRecord" => Key::MediaRecord, - "MediaRewind" => Key::MediaRewind, - "MediaStop" => Key::MediaStop, - "MediaTrackNext" => Key::MediaTrackNext, - "MediaTrackPrevious" => Key::MediaTrackPrevious, - "New" => Key::New, - "Open" => Key::Open, - "Print" => Key::Print, - "Save" => Key::Save, - "SpellCheck" => Key::SpellCheck, - "Key11" => Key::Key11, - "Key12" => Key::Key12, - "AudioBalanceLeft" => Key::AudioBalanceLeft, - "AudioBalanceRight" => Key::AudioBalanceRight, - "AudioBassBoostDown" => Key::AudioBassBoostDown, - "AudioBassBoostToggle" => Key::AudioBassBoostToggle, - "AudioBassBoostUp" => Key::AudioBassBoostUp, - "AudioFaderFront" => Key::AudioFaderFront, - "AudioFaderRear" => Key::AudioFaderRear, - "AudioSurroundModeNext" => Key::AudioSurroundModeNext, - "AudioTrebleDown" => Key::AudioTrebleDown, - "AudioTrebleUp" => Key::AudioTrebleUp, - "AudioVolumeDown" => Key::AudioVolumeDown, - "AudioVolumeUp" => Key::AudioVolumeUp, - "AudioVolumeMute" => Key::AudioVolumeMute, - "MicrophoneToggle" => Key::MicrophoneToggle, - "MicrophoneVolumeDown" => Key::MicrophoneVolumeDown, - "MicrophoneVolumeUp" => Key::MicrophoneVolumeUp, - "MicrophoneVolumeMute" => Key::MicrophoneVolumeMute, - "SpeechCorrectionList" => Key::SpeechCorrectionList, - "SpeechInputToggle" => Key::SpeechInputToggle, - "LaunchApplication1" => Key::LaunchApplication1, - "LaunchApplication2" => Key::LaunchApplication2, - "LaunchCalendar" => Key::LaunchCalendar, - "LaunchContacts" => Key::LaunchContacts, - "LaunchMail" => Key::LaunchMail, - "LaunchMediaPlayer" => Key::LaunchMediaPlayer, - "LaunchMusicPlayer" => Key::LaunchMusicPlayer, - "LaunchPhone" => Key::LaunchPhone, - "LaunchScreenSaver" => Key::LaunchScreenSaver, - "LaunchSpreadsheet" => Key::LaunchSpreadsheet, - "LaunchWebBrowser" => Key::LaunchWebBrowser, - "LaunchWebCam" => Key::LaunchWebCam, - "LaunchWordProcessor" => Key::LaunchWordProcessor, - "BrowserBack" => Key::BrowserBack, - "BrowserFavorites" => Key::BrowserFavorites, - "BrowserForward" => Key::BrowserForward, - "BrowserHome" => Key::BrowserHome, - "BrowserRefresh" => Key::BrowserRefresh, - "BrowserSearch" => Key::BrowserSearch, - "BrowserStop" => Key::BrowserStop, - "AppSwitch" => Key::AppSwitch, - "Call" => Key::Call, - "Camera" => Key::Camera, - "CameraFocus" => Key::CameraFocus, - "EndCall" => Key::EndCall, - "GoBack" => Key::GoBack, - "GoHome" => Key::GoHome, - "HeadsetHook" => Key::HeadsetHook, - "LastNumberRedial" => Key::LastNumberRedial, - "Notification" => Key::Notification, - "MannerMode" => Key::MannerMode, - "VoiceDial" => Key::VoiceDial, - "TV" => Key::TV, - "TV3DMode" => Key::TV3DMode, - "TVAntennaCable" => Key::TVAntennaCable, - "TVAudioDescription" => Key::TVAudioDescription, - "TVAudioDescriptionMixDown" => Key::TVAudioDescriptionMixDown, - "TVAudioDescriptionMixUp" => Key::TVAudioDescriptionMixUp, - "TVContentsMenu" => Key::TVContentsMenu, - "TVDataService" => Key::TVDataService, - "TVInput" => Key::TVInput, - "TVInputComponent1" => Key::TVInputComponent1, - "TVInputComponent2" => Key::TVInputComponent2, - "TVInputComposite1" => Key::TVInputComposite1, - "TVInputComposite2" => Key::TVInputComposite2, - "TVInputHDMI1" => Key::TVInputHDMI1, - "TVInputHDMI2" => Key::TVInputHDMI2, - "TVInputHDMI3" => Key::TVInputHDMI3, - "TVInputHDMI4" => Key::TVInputHDMI4, - "TVInputVGA1" => Key::TVInputVGA1, - "TVMediaContext" => Key::TVMediaContext, - "TVNetwork" => Key::TVNetwork, - "TVNumberEntry" => Key::TVNumberEntry, - "TVPower" => Key::TVPower, - "TVRadioService" => Key::TVRadioService, - "TVSatellite" => Key::TVSatellite, - "TVSatelliteBS" => Key::TVSatelliteBS, - "TVSatelliteCS" => Key::TVSatelliteCS, - "TVSatelliteToggle" => Key::TVSatelliteToggle, - "TVTerrestrialAnalog" => Key::TVTerrestrialAnalog, - "TVTerrestrialDigital" => Key::TVTerrestrialDigital, - "TVTimer" => Key::TVTimer, - "AVRInput" => Key::AVRInput, - "AVRPower" => Key::AVRPower, - "ColorF0Red" => Key::ColorF0Red, - "ColorF1Green" => Key::ColorF1Green, - "ColorF2Yellow" => Key::ColorF2Yellow, - "ColorF3Blue" => Key::ColorF3Blue, - "ColorF4Grey" => Key::ColorF4Grey, - "ColorF5Brown" => Key::ColorF5Brown, - "ClosedCaptionToggle" => Key::ClosedCaptionToggle, - "Dimmer" => Key::Dimmer, - "DisplaySwap" => Key::DisplaySwap, - "DVR" => Key::DVR, - "Exit" => Key::Exit, - "FavoriteClear0" => Key::FavoriteClear0, - "FavoriteClear1" => Key::FavoriteClear1, - "FavoriteClear2" => Key::FavoriteClear2, - "FavoriteClear3" => Key::FavoriteClear3, - "FavoriteRecall0" => Key::FavoriteRecall0, - "FavoriteRecall1" => Key::FavoriteRecall1, - "FavoriteRecall2" => Key::FavoriteRecall2, - "FavoriteRecall3" => Key::FavoriteRecall3, - "FavoriteStore0" => Key::FavoriteStore0, - "FavoriteStore1" => Key::FavoriteStore1, - "FavoriteStore2" => Key::FavoriteStore2, - "FavoriteStore3" => Key::FavoriteStore3, - "Guide" => Key::Guide, - "GuideNextDay" => Key::GuideNextDay, - "GuidePreviousDay" => Key::GuidePreviousDay, - "Info" => Key::Info, - "InstantReplay" => Key::InstantReplay, - "Link" => Key::Link, - "ListProgram" => Key::ListProgram, - "LiveContent" => Key::LiveContent, - "Lock" => Key::Lock, - "MediaApps" => Key::MediaApps, - "MediaAudioTrack" => Key::MediaAudioTrack, - "MediaLast" => Key::MediaLast, - "MediaSkipBackward" => Key::MediaSkipBackward, - "MediaSkipForward" => Key::MediaSkipForward, - "MediaStepBackward" => Key::MediaStepBackward, - "MediaStepForward" => Key::MediaStepForward, - "MediaTopMenu" => Key::MediaTopMenu, - "NavigateIn" => Key::NavigateIn, - "NavigateNext" => Key::NavigateNext, - "NavigateOut" => Key::NavigateOut, - "NavigatePrevious" => Key::NavigatePrevious, - "NextFavoriteChannel" => Key::NextFavoriteChannel, - "NextUserProfile" => Key::NextUserProfile, - "OnDemand" => Key::OnDemand, - "Pairing" => Key::Pairing, - "PinPDown" => Key::PinPDown, - "PinPMove" => Key::PinPMove, - "PinPToggle" => Key::PinPToggle, - "PinPUp" => Key::PinPUp, - "PlaySpeedDown" => Key::PlaySpeedDown, - "PlaySpeedReset" => Key::PlaySpeedReset, - "PlaySpeedUp" => Key::PlaySpeedUp, - "RandomToggle" => Key::RandomToggle, - "RcLowBattery" => Key::RcLowBattery, - "RecordSpeedNext" => Key::RecordSpeedNext, - "RfBypass" => Key::RfBypass, - "ScanChannelsToggle" => Key::ScanChannelsToggle, - "ScreenModeNext" => Key::ScreenModeNext, - "Settings" => Key::Settings, - "SplitScreenToggle" => Key::SplitScreenToggle, - "STBInput" => Key::STBInput, - "STBPower" => Key::STBPower, - "Subtitle" => Key::Subtitle, - "Teletext" => Key::Teletext, - "VideoModeNext" => Key::VideoModeNext, - "Wink" => Key::Wink, - "ZoomToggle" => Key::ZoomToggle, - "F1" => Key::F1, - "F2" => Key::F2, - "F3" => Key::F3, - "F4" => Key::F4, - "F5" => Key::F5, - "F6" => Key::F6, - "F7" => Key::F7, - "F8" => Key::F8, - "F9" => Key::F9, - "F10" => Key::F10, - "F11" => Key::F11, - "F12" => Key::F12, - "F13" => Key::F13, - "F14" => Key::F14, - "F15" => Key::F15, - "F16" => Key::F16, - "F17" => Key::F17, - "F18" => Key::F18, - "F19" => Key::F19, - "F20" => Key::F20, - "F21" => Key::F21, - "F22" => Key::F22, - "F23" => Key::F23, - "F24" => Key::F24, - "F25" => Key::F25, - "F26" => Key::F26, - "F27" => Key::F27, - "F28" => Key::F28, - "F29" => Key::F29, - "F30" => Key::F30, - "F31" => Key::F31, - "F32" => Key::F32, - "F33" => Key::F33, - "F34" => Key::F34, - "F35" => Key::F35, - string @ _ => Key::Character(string), - } - } - - pub fn as_key_code_attribute_value(&self) -> &str { - match self { - Key::Character(character) => character, - Key::Unidentified(_) => "Unidentified", - Key::Dead(_) => "Dead", - Key::Alt => "Alt", - Key::AltGraph => "AltGraph", - Key::CapsLock => "CapsLock", - Key::Control => "Control", - Key::Fn => "Fn", - Key::FnLock => "FnLock", - Key::NumLock => "NumLock", - Key::ScrollLock => "ScrollLock", - Key::Shift => "Shift", - Key::Symbol => "Symbol", - Key::SymbolLock => "SymbolLock", - Key::Hyper => "Hyper", - Key::Super => "Meta", - Key::Enter => "Enter", - Key::Tab => "Tab", - Key::Space => "Space", - Key::ArrowDown => "ArrowDown", - Key::ArrowLeft => "ArrowLeft", - Key::ArrowRight => "ArrowRight", - Key::ArrowUp => "ArrowUp", - Key::End => "End", - Key::Home => "Home", - Key::PageDown => "PageDown", - Key::PageUp => "PageUp", - Key::Backspace => "Backspace", - Key::Clear => "Clear", - Key::Copy => "Copy", - Key::CrSel => "CrSel", - Key::Cut => "Cut", - Key::Delete => "Delete", - Key::EraseEof => "EraseEof", - Key::ExSel => "ExSel", - Key::Insert => "Insert", - Key::Paste => "Paste", - Key::Redo => "Redo", - Key::Undo => "Undo", - Key::Accept => "Accept", - Key::Again => "Again", - Key::Attn => "Attn", - Key::Cancel => "Cancel", - Key::ContextMenu => "ContextMenu", - Key::Escape => "Escape", - Key::Execute => "Execute", - Key::Find => "Find", - Key::Help => "Help", - Key::Pause => "Pause", - Key::Play => "Play", - Key::Props => "Props", - Key::Select => "Select", - Key::ZoomIn => "ZoomIn", - Key::ZoomOut => "ZoomOut", - Key::BrightnessDown => "BrightnessDown", - Key::BrightnessUp => "BrightnessUp", - Key::Eject => "Eject", - Key::LogOff => "LogOff", - Key::Power => "Power", - Key::PowerOff => "PowerOff", - Key::PrintScreen => "PrintScreen", - Key::Hibernate => "Hibernate", - Key::Standby => "Standby", - Key::WakeUp => "WakeUp", - Key::AllCandidates => "AllCandidates", - Key::Alphanumeric => "Alphanumeric", - Key::CodeInput => "CodeInput", - Key::Compose => "Compose", - Key::Convert => "Convert", - Key::FinalMode => "FinalMode", - Key::GroupFirst => "GroupFirst", - Key::GroupLast => "GroupLast", - Key::GroupNext => "GroupNext", - Key::GroupPrevious => "GroupPrevious", - Key::ModeChange => "ModeChange", - Key::NextCandidate => "NextCandidate", - Key::NonConvert => "NonConvert", - Key::PreviousCandidate => "PreviousCandidate", - Key::Process => "Process", - Key::SingleCandidate => "SingleCandidate", - Key::HangulMode => "HangulMode", - Key::HanjaMode => "HanjaMode", - Key::JunjaMode => "JunjaMode", - Key::Eisu => "Eisu", - Key::Hankaku => "Hankaku", - Key::Hiragana => "Hiragana", - Key::HiraganaKatakana => "HiraganaKatakana", - Key::KanaMode => "KanaMode", - Key::KanjiMode => "KanjiMode", - Key::Katakana => "Katakana", - Key::Romaji => "Romaji", - Key::Zenkaku => "Zenkaku", - Key::ZenkakuHankaku => "ZenkakuHankaku", - Key::Soft1 => "Soft1", - Key::Soft2 => "Soft2", - Key::Soft3 => "Soft3", - Key::Soft4 => "Soft4", - Key::ChannelDown => "ChannelDown", - Key::ChannelUp => "ChannelUp", - Key::Close => "Close", - Key::MailForward => "MailForward", - Key::MailReply => "MailReply", - Key::MailSend => "MailSend", - Key::MediaClose => "MediaClose", - Key::MediaFastForward => "MediaFastForward", - Key::MediaPause => "MediaPause", - Key::MediaPlay => "MediaPlay", - Key::MediaPlayPause => "MediaPlayPause", - Key::MediaRecord => "MediaRecord", - Key::MediaRewind => "MediaRewind", - Key::MediaStop => "MediaStop", - Key::MediaTrackNext => "MediaTrackNext", - Key::MediaTrackPrevious => "MediaTrackPrevious", - Key::New => "New", - Key::Open => "Open", - Key::Print => "Print", - Key::Save => "Save", - Key::SpellCheck => "SpellCheck", - Key::Key11 => "Key11", - Key::Key12 => "Key12", - Key::AudioBalanceLeft => "AudioBalanceLeft", - Key::AudioBalanceRight => "AudioBalanceRight", - Key::AudioBassBoostDown => "AudioBassBoostDown", - Key::AudioBassBoostToggle => "AudioBassBoostToggle", - Key::AudioBassBoostUp => "AudioBassBoostUp", - Key::AudioFaderFront => "AudioFaderFront", - Key::AudioFaderRear => "AudioFaderRear", - Key::AudioSurroundModeNext => "AudioSurroundModeNext", - Key::AudioTrebleDown => "AudioTrebleDown", - Key::AudioTrebleUp => "AudioTrebleUp", - Key::AudioVolumeDown => "AudioVolumeDown", - Key::AudioVolumeUp => "AudioVolumeUp", - Key::AudioVolumeMute => "AudioVolumeMute", - Key::MicrophoneToggle => "MicrophoneToggle", - Key::MicrophoneVolumeDown => "MicrophoneVolumeDown", - Key::MicrophoneVolumeUp => "MicrophoneVolumeUp", - Key::MicrophoneVolumeMute => "MicrophoneVolumeMute", - Key::SpeechCorrectionList => "SpeechCorrectionList", - Key::SpeechInputToggle => "SpeechInputToggle", - Key::LaunchApplication1 => "LaunchApplication1", - Key::LaunchApplication2 => "LaunchApplication2", - Key::LaunchCalendar => "LaunchCalendar", - Key::LaunchContacts => "LaunchContacts", - Key::LaunchMail => "LaunchMail", - Key::LaunchMediaPlayer => "LaunchMediaPlayer", - Key::LaunchMusicPlayer => "LaunchMusicPlayer", - Key::LaunchPhone => "LaunchPhone", - Key::LaunchScreenSaver => "LaunchScreenSaver", - Key::LaunchSpreadsheet => "LaunchSpreadsheet", - Key::LaunchWebBrowser => "LaunchWebBrowser", - Key::LaunchWebCam => "LaunchWebCam", - Key::LaunchWordProcessor => "LaunchWordProcessor", - Key::BrowserBack => "BrowserBack", - Key::BrowserFavorites => "BrowserFavorites", - Key::BrowserForward => "BrowserForward", - Key::BrowserHome => "BrowserHome", - Key::BrowserRefresh => "BrowserRefresh", - Key::BrowserSearch => "BrowserSearch", - Key::BrowserStop => "BrowserStop", - Key::AppSwitch => "AppSwitch", - Key::Call => "Call", - Key::Camera => "Camera", - Key::CameraFocus => "CameraFocus", - Key::EndCall => "EndCall", - Key::GoBack => "GoBack", - Key::GoHome => "GoHome", - Key::HeadsetHook => "HeadsetHook", - Key::LastNumberRedial => "LastNumberRedial", - Key::Notification => "Notification", - Key::MannerMode => "MannerMode", - Key::VoiceDial => "VoiceDial", - Key::TV => "TV", - Key::TV3DMode => "TV3DMode", - Key::TVAntennaCable => "TVAntennaCable", - Key::TVAudioDescription => "TVAudioDescription", - Key::TVAudioDescriptionMixDown => "TVAudioDescriptionMixDown", - Key::TVAudioDescriptionMixUp => "TVAudioDescriptionMixUp", - Key::TVContentsMenu => "TVContentsMenu", - Key::TVDataService => "TVDataService", - Key::TVInput => "TVInput", - Key::TVInputComponent1 => "TVInputComponent1", - Key::TVInputComponent2 => "TVInputComponent2", - Key::TVInputComposite1 => "TVInputComposite1", - Key::TVInputComposite2 => "TVInputComposite2", - Key::TVInputHDMI1 => "TVInputHDMI1", - Key::TVInputHDMI2 => "TVInputHDMI2", - Key::TVInputHDMI3 => "TVInputHDMI3", - Key::TVInputHDMI4 => "TVInputHDMI4", - Key::TVInputVGA1 => "TVInputVGA1", - Key::TVMediaContext => "TVMediaContext", - Key::TVNetwork => "TVNetwork", - Key::TVNumberEntry => "TVNumberEntry", - Key::TVPower => "TVPower", - Key::TVRadioService => "TVRadioService", - Key::TVSatellite => "TVSatellite", - Key::TVSatelliteBS => "TVSatelliteBS", - Key::TVSatelliteCS => "TVSatelliteCS", - Key::TVSatelliteToggle => "TVSatelliteToggle", - Key::TVTerrestrialAnalog => "TVTerrestrialAnalog", - Key::TVTerrestrialDigital => "TVTerrestrialDigital", - Key::TVTimer => "TVTimer", - Key::AVRInput => "AVRInput", - Key::AVRPower => "AVRPower", - Key::ColorF0Red => "ColorF0Red", - Key::ColorF1Green => "ColorF1Green", - Key::ColorF2Yellow => "ColorF2Yellow", - Key::ColorF3Blue => "ColorF3Blue", - Key::ColorF4Grey => "ColorF4Grey", - Key::ColorF5Brown => "ColorF5Brown", - Key::ClosedCaptionToggle => "ClosedCaptionToggle", - Key::Dimmer => "Dimmer", - Key::DisplaySwap => "DisplaySwap", - Key::DVR => "DVR", - Key::Exit => "Exit", - Key::FavoriteClear0 => "FavoriteClear0", - Key::FavoriteClear1 => "FavoriteClear1", - Key::FavoriteClear2 => "FavoriteClear2", - Key::FavoriteClear3 => "FavoriteClear3", - Key::FavoriteRecall0 => "FavoriteRecall0", - Key::FavoriteRecall1 => "FavoriteRecall1", - Key::FavoriteRecall2 => "FavoriteRecall2", - Key::FavoriteRecall3 => "FavoriteRecall3", - Key::FavoriteStore0 => "FavoriteStore0", - Key::FavoriteStore1 => "FavoriteStore1", - Key::FavoriteStore2 => "FavoriteStore2", - Key::FavoriteStore3 => "FavoriteStore3", - Key::Guide => "Guide", - Key::GuideNextDay => "GuideNextDay", - Key::GuidePreviousDay => "GuidePreviousDay", - Key::Info => "Info", - Key::InstantReplay => "InstantReplay", - Key::Link => "Link", - Key::ListProgram => "ListProgram", - Key::LiveContent => "LiveContent", - Key::Lock => "Lock", - Key::MediaApps => "MediaApps", - Key::MediaAudioTrack => "MediaAudioTrack", - Key::MediaLast => "MediaLast", - Key::MediaSkipBackward => "MediaSkipBackward", - Key::MediaSkipForward => "MediaSkipForward", - Key::MediaStepBackward => "MediaStepBackward", - Key::MediaStepForward => "MediaStepForward", - Key::MediaTopMenu => "MediaTopMenu", - Key::NavigateIn => "NavigateIn", - Key::NavigateNext => "NavigateNext", - Key::NavigateOut => "NavigateOut", - Key::NavigatePrevious => "NavigatePrevious", - Key::NextFavoriteChannel => "NextFavoriteChannel", - Key::NextUserProfile => "NextUserProfile", - Key::OnDemand => "OnDemand", - Key::Pairing => "Pairing", - Key::PinPDown => "PinPDown", - Key::PinPMove => "PinPMove", - Key::PinPToggle => "PinPToggle", - Key::PinPUp => "PinPUp", - Key::PlaySpeedDown => "PlaySpeedDown", - Key::PlaySpeedReset => "PlaySpeedReset", - Key::PlaySpeedUp => "PlaySpeedUp", - Key::RandomToggle => "RandomToggle", - Key::RcLowBattery => "RcLowBattery", - Key::RecordSpeedNext => "RecordSpeedNext", - Key::RfBypass => "RfBypass", - Key::ScanChannelsToggle => "ScanChannelsToggle", - Key::ScreenModeNext => "ScreenModeNext", - Key::Settings => "Settings", - Key::SplitScreenToggle => "SplitScreenToggle", - Key::STBInput => "STBInput", - Key::STBPower => "STBPower", - Key::Subtitle => "Subtitle", - Key::Teletext => "Teletext", - Key::VideoModeNext => "VideoModeNext", - Key::Wink => "Wink", - Key::ZoomToggle => "ZoomToggle", - Key::F1 => "F1", - Key::F2 => "F2", - Key::F3 => "F3", - Key::F4 => "F4", - Key::F5 => "F5", - Key::F6 => "F6", - Key::F7 => "F7", - Key::F8 => "F8", - Key::F9 => "F9", - Key::F10 => "F10", - Key::F11 => "F11", - Key::F12 => "F12", - Key::F13 => "F13", - Key::F14 => "F14", - Key::F15 => "F15", - Key::F16 => "F16", - Key::F17 => "F17", - Key::F18 => "F18", - Key::F19 => "F19", - Key::F20 => "F20", - Key::F21 => "F21", - Key::F22 => "F22", - Key::F23 => "F23", - Key::F24 => "F24", - Key::F25 => "F25", - Key::F26 => "F26", - Key::F27 => "F27", - Key::F28 => "F28", - Key::F29 => "F29", - Key::F30 => "F30", - Key::F31 => "F31", - Key::F32 => "F32", - Key::F33 => "F33", - Key::F34 => "F34", - Key::F35 => "F35", - } - } -} - impl<'a> Key<'a> { pub fn to_text(&self) -> Option<&'a str> { match self { diff --git a/src/platform_impl/web/keyboard.rs b/src/platform_impl/web/keyboard.rs new file mode 100644 index 0000000000..35b1cbfa93 --- /dev/null +++ b/src/platform_impl/web/keyboard.rs @@ -0,0 +1,521 @@ +use crate::keyboard::{Key, KeyCode, NativeKeyCode}; + +impl<'a> Key<'a> { + pub(crate) fn from_key_attribute_value(kav: &'a str) -> Self { + match kav { + // TODO: Report this in a better way. + "Unidentified" => Key::Unidentified(NativeKeyCode::Web("Unidentified")), + "Dead" => Key::Dead(None), + "Alt" => Key::Alt, + "AltGraph" => Key::AltGraph, + "CapsLock" => Key::CapsLock, + "Control" => Key::Control, + "Fn" => Key::Fn, + "FnLock" => Key::FnLock, + "NumLock" => Key::NumLock, + "ScrollLock" => Key::ScrollLock, + "Shift" => Key::Shift, + "Symbol" => Key::Symbol, + "SymbolLock" => Key::SymbolLock, + "Hyper" => Key::Hyper, + "Meta" => Key::Super, + "Enter" => Key::Enter, + "Tab" => Key::Tab, + " " => Key::Space, + "ArrowDown" => Key::ArrowDown, + "ArrowLeft" => Key::ArrowLeft, + "ArrowRight" => Key::ArrowRight, + "ArrowUp" => Key::ArrowUp, + "End" => Key::End, + "Home" => Key::Home, + "PageDown" => Key::PageDown, + "PageUp" => Key::PageUp, + "Backspace" => Key::Backspace, + "Clear" => Key::Clear, + "Copy" => Key::Copy, + "CrSel" => Key::CrSel, + "Cut" => Key::Cut, + "Delete" => Key::Delete, + "EraseEof" => Key::EraseEof, + "ExSel" => Key::ExSel, + "Insert" => Key::Insert, + "Paste" => Key::Paste, + "Redo" => Key::Redo, + "Undo" => Key::Undo, + "Accept" => Key::Accept, + "Again" => Key::Again, + "Attn" => Key::Attn, + "Cancel" => Key::Cancel, + "ContextMenu" => Key::ContextMenu, + "Escape" => Key::Escape, + "Execute" => Key::Execute, + "Find" => Key::Find, + "Help" => Key::Help, + "Pause" => Key::Pause, + "Play" => Key::Play, + "Props" => Key::Props, + "Select" => Key::Select, + "ZoomIn" => Key::ZoomIn, + "ZoomOut" => Key::ZoomOut, + "BrightnessDown" => Key::BrightnessDown, + "BrightnessUp" => Key::BrightnessUp, + "Eject" => Key::Eject, + "LogOff" => Key::LogOff, + "Power" => Key::Power, + "PowerOff" => Key::PowerOff, + "PrintScreen" => Key::PrintScreen, + "Hibernate" => Key::Hibernate, + "Standby" => Key::Standby, + "WakeUp" => Key::WakeUp, + "AllCandidates" => Key::AllCandidates, + "Alphanumeric" => Key::Alphanumeric, + "CodeInput" => Key::CodeInput, + "Compose" => Key::Compose, + "Convert" => Key::Convert, + "FinalMode" => Key::FinalMode, + "GroupFirst" => Key::GroupFirst, + "GroupLast" => Key::GroupLast, + "GroupNext" => Key::GroupNext, + "GroupPrevious" => Key::GroupPrevious, + "ModeChange" => Key::ModeChange, + "NextCandidate" => Key::NextCandidate, + "NonConvert" => Key::NonConvert, + "PreviousCandidate" => Key::PreviousCandidate, + "Process" => Key::Process, + "SingleCandidate" => Key::SingleCandidate, + "HangulMode" => Key::HangulMode, + "HanjaMode" => Key::HanjaMode, + "JunjaMode" => Key::JunjaMode, + "Eisu" => Key::Eisu, + "Hankaku" => Key::Hankaku, + "Hiragana" => Key::Hiragana, + "HiraganaKatakana" => Key::HiraganaKatakana, + "KanaMode" => Key::KanaMode, + "KanjiMode" => Key::KanjiMode, + "Katakana" => Key::Katakana, + "Romaji" => Key::Romaji, + "Zenkaku" => Key::Zenkaku, + "ZenkakuHankaku" => Key::ZenkakuHankaku, + "Soft1" => Key::Soft1, + "Soft2" => Key::Soft2, + "Soft3" => Key::Soft3, + "Soft4" => Key::Soft4, + "ChannelDown" => Key::ChannelDown, + "ChannelUp" => Key::ChannelUp, + "Close" => Key::Close, + "MailForward" => Key::MailForward, + "MailReply" => Key::MailReply, + "MailSend" => Key::MailSend, + "MediaClose" => Key::MediaClose, + "MediaFastForward" => Key::MediaFastForward, + "MediaPause" => Key::MediaPause, + "MediaPlay" => Key::MediaPlay, + "MediaPlayPause" => Key::MediaPlayPause, + "MediaRecord" => Key::MediaRecord, + "MediaRewind" => Key::MediaRewind, + "MediaStop" => Key::MediaStop, + "MediaTrackNext" => Key::MediaTrackNext, + "MediaTrackPrevious" => Key::MediaTrackPrevious, + "New" => Key::New, + "Open" => Key::Open, + "Print" => Key::Print, + "Save" => Key::Save, + "SpellCheck" => Key::SpellCheck, + "Key11" => Key::Key11, + "Key12" => Key::Key12, + "AudioBalanceLeft" => Key::AudioBalanceLeft, + "AudioBalanceRight" => Key::AudioBalanceRight, + "AudioBassBoostDown" => Key::AudioBassBoostDown, + "AudioBassBoostToggle" => Key::AudioBassBoostToggle, + "AudioBassBoostUp" => Key::AudioBassBoostUp, + "AudioFaderFront" => Key::AudioFaderFront, + "AudioFaderRear" => Key::AudioFaderRear, + "AudioSurroundModeNext" => Key::AudioSurroundModeNext, + "AudioTrebleDown" => Key::AudioTrebleDown, + "AudioTrebleUp" => Key::AudioTrebleUp, + "AudioVolumeDown" => Key::AudioVolumeDown, + "AudioVolumeUp" => Key::AudioVolumeUp, + "AudioVolumeMute" => Key::AudioVolumeMute, + "MicrophoneToggle" => Key::MicrophoneToggle, + "MicrophoneVolumeDown" => Key::MicrophoneVolumeDown, + "MicrophoneVolumeUp" => Key::MicrophoneVolumeUp, + "MicrophoneVolumeMute" => Key::MicrophoneVolumeMute, + "SpeechCorrectionList" => Key::SpeechCorrectionList, + "SpeechInputToggle" => Key::SpeechInputToggle, + "LaunchApplication1" => Key::LaunchApplication1, + "LaunchApplication2" => Key::LaunchApplication2, + "LaunchCalendar" => Key::LaunchCalendar, + "LaunchContacts" => Key::LaunchContacts, + "LaunchMail" => Key::LaunchMail, + "LaunchMediaPlayer" => Key::LaunchMediaPlayer, + "LaunchMusicPlayer" => Key::LaunchMusicPlayer, + "LaunchPhone" => Key::LaunchPhone, + "LaunchScreenSaver" => Key::LaunchScreenSaver, + "LaunchSpreadsheet" => Key::LaunchSpreadsheet, + "LaunchWebBrowser" => Key::LaunchWebBrowser, + "LaunchWebCam" => Key::LaunchWebCam, + "LaunchWordProcessor" => Key::LaunchWordProcessor, + "BrowserBack" => Key::BrowserBack, + "BrowserFavorites" => Key::BrowserFavorites, + "BrowserForward" => Key::BrowserForward, + "BrowserHome" => Key::BrowserHome, + "BrowserRefresh" => Key::BrowserRefresh, + "BrowserSearch" => Key::BrowserSearch, + "BrowserStop" => Key::BrowserStop, + "AppSwitch" => Key::AppSwitch, + "Call" => Key::Call, + "Camera" => Key::Camera, + "CameraFocus" => Key::CameraFocus, + "EndCall" => Key::EndCall, + "GoBack" => Key::GoBack, + "GoHome" => Key::GoHome, + "HeadsetHook" => Key::HeadsetHook, + "LastNumberRedial" => Key::LastNumberRedial, + "Notification" => Key::Notification, + "MannerMode" => Key::MannerMode, + "VoiceDial" => Key::VoiceDial, + "TV" => Key::TV, + "TV3DMode" => Key::TV3DMode, + "TVAntennaCable" => Key::TVAntennaCable, + "TVAudioDescription" => Key::TVAudioDescription, + "TVAudioDescriptionMixDown" => Key::TVAudioDescriptionMixDown, + "TVAudioDescriptionMixUp" => Key::TVAudioDescriptionMixUp, + "TVContentsMenu" => Key::TVContentsMenu, + "TVDataService" => Key::TVDataService, + "TVInput" => Key::TVInput, + "TVInputComponent1" => Key::TVInputComponent1, + "TVInputComponent2" => Key::TVInputComponent2, + "TVInputComposite1" => Key::TVInputComposite1, + "TVInputComposite2" => Key::TVInputComposite2, + "TVInputHDMI1" => Key::TVInputHDMI1, + "TVInputHDMI2" => Key::TVInputHDMI2, + "TVInputHDMI3" => Key::TVInputHDMI3, + "TVInputHDMI4" => Key::TVInputHDMI4, + "TVInputVGA1" => Key::TVInputVGA1, + "TVMediaContext" => Key::TVMediaContext, + "TVNetwork" => Key::TVNetwork, + "TVNumberEntry" => Key::TVNumberEntry, + "TVPower" => Key::TVPower, + "TVRadioService" => Key::TVRadioService, + "TVSatellite" => Key::TVSatellite, + "TVSatelliteBS" => Key::TVSatelliteBS, + "TVSatelliteCS" => Key::TVSatelliteCS, + "TVSatelliteToggle" => Key::TVSatelliteToggle, + "TVTerrestrialAnalog" => Key::TVTerrestrialAnalog, + "TVTerrestrialDigital" => Key::TVTerrestrialDigital, + "TVTimer" => Key::TVTimer, + "AVRInput" => Key::AVRInput, + "AVRPower" => Key::AVRPower, + "ColorF0Red" => Key::ColorF0Red, + "ColorF1Green" => Key::ColorF1Green, + "ColorF2Yellow" => Key::ColorF2Yellow, + "ColorF3Blue" => Key::ColorF3Blue, + "ColorF4Grey" => Key::ColorF4Grey, + "ColorF5Brown" => Key::ColorF5Brown, + "ClosedCaptionToggle" => Key::ClosedCaptionToggle, + "Dimmer" => Key::Dimmer, + "DisplaySwap" => Key::DisplaySwap, + "DVR" => Key::DVR, + "Exit" => Key::Exit, + "FavoriteClear0" => Key::FavoriteClear0, + "FavoriteClear1" => Key::FavoriteClear1, + "FavoriteClear2" => Key::FavoriteClear2, + "FavoriteClear3" => Key::FavoriteClear3, + "FavoriteRecall0" => Key::FavoriteRecall0, + "FavoriteRecall1" => Key::FavoriteRecall1, + "FavoriteRecall2" => Key::FavoriteRecall2, + "FavoriteRecall3" => Key::FavoriteRecall3, + "FavoriteStore0" => Key::FavoriteStore0, + "FavoriteStore1" => Key::FavoriteStore1, + "FavoriteStore2" => Key::FavoriteStore2, + "FavoriteStore3" => Key::FavoriteStore3, + "Guide" => Key::Guide, + "GuideNextDay" => Key::GuideNextDay, + "GuidePreviousDay" => Key::GuidePreviousDay, + "Info" => Key::Info, + "InstantReplay" => Key::InstantReplay, + "Link" => Key::Link, + "ListProgram" => Key::ListProgram, + "LiveContent" => Key::LiveContent, + "Lock" => Key::Lock, + "MediaApps" => Key::MediaApps, + "MediaAudioTrack" => Key::MediaAudioTrack, + "MediaLast" => Key::MediaLast, + "MediaSkipBackward" => Key::MediaSkipBackward, + "MediaSkipForward" => Key::MediaSkipForward, + "MediaStepBackward" => Key::MediaStepBackward, + "MediaStepForward" => Key::MediaStepForward, + "MediaTopMenu" => Key::MediaTopMenu, + "NavigateIn" => Key::NavigateIn, + "NavigateNext" => Key::NavigateNext, + "NavigateOut" => Key::NavigateOut, + "NavigatePrevious" => Key::NavigatePrevious, + "NextFavoriteChannel" => Key::NextFavoriteChannel, + "NextUserProfile" => Key::NextUserProfile, + "OnDemand" => Key::OnDemand, + "Pairing" => Key::Pairing, + "PinPDown" => Key::PinPDown, + "PinPMove" => Key::PinPMove, + "PinPToggle" => Key::PinPToggle, + "PinPUp" => Key::PinPUp, + "PlaySpeedDown" => Key::PlaySpeedDown, + "PlaySpeedReset" => Key::PlaySpeedReset, + "PlaySpeedUp" => Key::PlaySpeedUp, + "RandomToggle" => Key::RandomToggle, + "RcLowBattery" => Key::RcLowBattery, + "RecordSpeedNext" => Key::RecordSpeedNext, + "RfBypass" => Key::RfBypass, + "ScanChannelsToggle" => Key::ScanChannelsToggle, + "ScreenModeNext" => Key::ScreenModeNext, + "Settings" => Key::Settings, + "SplitScreenToggle" => Key::SplitScreenToggle, + "STBInput" => Key::STBInput, + "STBPower" => Key::STBPower, + "Subtitle" => Key::Subtitle, + "Teletext" => Key::Teletext, + "VideoModeNext" => Key::VideoModeNext, + "Wink" => Key::Wink, + "ZoomToggle" => Key::ZoomToggle, + "F1" => Key::F1, + "F2" => Key::F2, + "F3" => Key::F3, + "F4" => Key::F4, + "F5" => Key::F5, + "F6" => Key::F6, + "F7" => Key::F7, + "F8" => Key::F8, + "F9" => Key::F9, + "F10" => Key::F10, + "F11" => Key::F11, + "F12" => Key::F12, + "F13" => Key::F13, + "F14" => Key::F14, + "F15" => Key::F15, + "F16" => Key::F16, + "F17" => Key::F17, + "F18" => Key::F18, + "F19" => Key::F19, + "F20" => Key::F20, + "F21" => Key::F21, + "F22" => Key::F22, + "F23" => Key::F23, + "F24" => Key::F24, + "F25" => Key::F25, + "F26" => Key::F26, + "F27" => Key::F27, + "F28" => Key::F28, + "F29" => Key::F29, + "F30" => Key::F30, + "F31" => Key::F31, + "F32" => Key::F32, + "F33" => Key::F33, + "F34" => Key::F34, + "F35" => Key::F35, + string @ _ => Key::Character(string), + } + } +} + +impl KeyCode { + pub fn from_key_code_attribute_value(kcav: &str) -> Self { + match kcav { + "Backquote" => KeyCode::Backquote, + "Backslash" => KeyCode::Backslash, + "BracketLeft" => KeyCode::BracketLeft, + "BracketRight" => KeyCode::BracketRight, + "Comma" => KeyCode::Comma, + "Digit0" => KeyCode::Digit0, + "Digit1" => KeyCode::Digit1, + "Digit2" => KeyCode::Digit2, + "Digit3" => KeyCode::Digit3, + "Digit4" => KeyCode::Digit4, + "Digit5" => KeyCode::Digit5, + "Digit6" => KeyCode::Digit6, + "Digit7" => KeyCode::Digit7, + "Digit8" => KeyCode::Digit8, + "Digit9" => KeyCode::Digit9, + "Equal" => KeyCode::Equal, + "IntlBackslash" => KeyCode::IntlBackslash, + "IntlRo" => KeyCode::IntlRo, + "IntlYen" => KeyCode::IntlYen, + "KeyA" => KeyCode::KeyA, + "KeyB" => KeyCode::KeyB, + "KeyC" => KeyCode::KeyC, + "KeyD" => KeyCode::KeyD, + "KeyE" => KeyCode::KeyE, + "KeyF" => KeyCode::KeyF, + "KeyG" => KeyCode::KeyG, + "KeyH" => KeyCode::KeyH, + "KeyI" => KeyCode::KeyI, + "KeyJ" => KeyCode::KeyJ, + "KeyK" => KeyCode::KeyK, + "KeyL" => KeyCode::KeyL, + "KeyM" => KeyCode::KeyM, + "KeyN" => KeyCode::KeyN, + "KeyO" => KeyCode::KeyO, + "KeyP" => KeyCode::KeyP, + "KeyQ" => KeyCode::KeyQ, + "KeyR" => KeyCode::KeyR, + "KeyS" => KeyCode::KeyS, + "KeyT" => KeyCode::KeyT, + "KeyU" => KeyCode::KeyU, + "KeyV" => KeyCode::KeyV, + "KeyW" => KeyCode::KeyW, + "KeyX" => KeyCode::KeyX, + "KeyY" => KeyCode::KeyY, + "KeyZ" => KeyCode::KeyZ, + "Minus" => KeyCode::Minus, + "Period" => KeyCode::Period, + "Quote" => KeyCode::Quote, + "Semicolon" => KeyCode::Semicolon, + "Slash" => KeyCode::Slash, + "AltLeft" => KeyCode::AltLeft, + "AltRight" => KeyCode::AltRight, + "Backspace" => KeyCode::Backspace, + "CapsLock" => KeyCode::CapsLock, + "ContextMenu" => KeyCode::ContextMenu, + "ControlLeft" => KeyCode::ControlLeft, + "ControlRight" => KeyCode::ControlRight, + "Enter" => KeyCode::Enter, + "MetaLeft" => KeyCode::SuperLeft, + "MetaRight" => KeyCode::SuperRight, + "ShiftLeft" => KeyCode::ShiftLeft, + "ShiftRight" => KeyCode::ShiftRight, + "Space" => KeyCode::Space, + "Tab" => KeyCode::Tab, + "Convert" => KeyCode::Convert, + "KanaMode" => KeyCode::KanaMode, + "Lang1" => KeyCode::Lang1, + "Lang2" => KeyCode::Lang2, + "Lang3" => KeyCode::Lang3, + "Lang4" => KeyCode::Lang4, + "Lang5" => KeyCode::Lang5, + "NonConvert" => KeyCode::NonConvert, + "Delete" => KeyCode::Delete, + "End" => KeyCode::End, + "Help" => KeyCode::Help, + "Home" => KeyCode::Home, + "Insert" => KeyCode::Insert, + "PageDown" => KeyCode::PageDown, + "PageUp" => KeyCode::PageUp, + "ArrowDown" => KeyCode::ArrowDown, + "ArrowLeft" => KeyCode::ArrowLeft, + "ArrowRight" => KeyCode::ArrowRight, + "ArrowUp" => KeyCode::ArrowUp, + "NumLock" => KeyCode::NumLock, + "Numpad0" => KeyCode::Numpad0, + "Numpad1" => KeyCode::Numpad1, + "Numpad2" => KeyCode::Numpad2, + "Numpad3" => KeyCode::Numpad3, + "Numpad4" => KeyCode::Numpad4, + "Numpad5" => KeyCode::Numpad5, + "Numpad6" => KeyCode::Numpad6, + "Numpad7" => KeyCode::Numpad7, + "Numpad8" => KeyCode::Numpad8, + "Numpad9" => KeyCode::Numpad9, + "NumpadAdd" => KeyCode::NumpadAdd, + "NumpadBackspace" => KeyCode::NumpadBackspace, + "NumpadClear" => KeyCode::NumpadClear, + "NumpadClearEntry" => KeyCode::NumpadClearEntry, + "NumpadComma" => KeyCode::NumpadComma, + "NumpadDecimal" => KeyCode::NumpadDecimal, + "NumpadDivide" => KeyCode::NumpadDivide, + "NumpadEnter" => KeyCode::NumpadEnter, + "NumpadEqual" => KeyCode::NumpadEqual, + "NumpadHash" => KeyCode::NumpadHash, + "NumpadMemoryAdd" => KeyCode::NumpadMemoryAdd, + "NumpadMemoryClear" => KeyCode::NumpadMemoryClear, + "NumpadMemoryRecall" => KeyCode::NumpadMemoryRecall, + "NumpadMemoryStore" => KeyCode::NumpadMemoryStore, + "NumpadMemorySubtract" => KeyCode::NumpadMemorySubtract, + "NumpadMultiply" => KeyCode::NumpadMultiply, + "NumpadParenLeft" => KeyCode::NumpadParenLeft, + "NumpadParenRight" => KeyCode::NumpadParenRight, + "NumpadStar" => KeyCode::NumpadStar, + "NumpadSubtract" => KeyCode::NumpadSubtract, + "Escape" => KeyCode::Escape, + "Fn" => KeyCode::Fn, + "FnLock" => KeyCode::FnLock, + "PrintScreen" => KeyCode::PrintScreen, + "ScrollLock" => KeyCode::ScrollLock, + "Pause" => KeyCode::Pause, + "BrowserBack" => KeyCode::BrowserBack, + "BrowserFavorites" => KeyCode::BrowserFavorites, + "BrowserForward" => KeyCode::BrowserForward, + "BrowserHome" => KeyCode::BrowserHome, + "BrowserRefresh" => KeyCode::BrowserRefresh, + "BrowserSearch" => KeyCode::BrowserSearch, + "BrowserStop" => KeyCode::BrowserStop, + "Eject" => KeyCode::Eject, + "LaunchApp1" => KeyCode::LaunchApp1, + "LaunchApp2" => KeyCode::LaunchApp2, + "LaunchMail" => KeyCode::LaunchMail, + "MediaPlayPause" => KeyCode::MediaPlayPause, + "MediaSelect" => KeyCode::MediaSelect, + "MediaStop" => KeyCode::MediaStop, + "MediaTrackNext" => KeyCode::MediaTrackNext, + "MediaTrackPrevious" => KeyCode::MediaTrackPrevious, + "Power" => KeyCode::Power, + "Sleep" => KeyCode::Sleep, + "AudioVolumeDown" => KeyCode::AudioVolumeDown, + "AudioVolumeMute" => KeyCode::AudioVolumeMute, + "AudioVolumeUp" => KeyCode::AudioVolumeUp, + "WakeUp" => KeyCode::WakeUp, + "Hyper" => KeyCode::Hyper, + "Turbo" => KeyCode::Turbo, + "Abort" => KeyCode::Abort, + "Resume" => KeyCode::Resume, + "Suspend" => KeyCode::Suspend, + "Again" => KeyCode::Again, + "Copy" => KeyCode::Copy, + "Cut" => KeyCode::Cut, + "Find" => KeyCode::Find, + "Open" => KeyCode::Open, + "Paste" => KeyCode::Paste, + "Props" => KeyCode::Props, + "Select" => KeyCode::Select, + "Undo" => KeyCode::Undo, + "Hiragana" => KeyCode::Hiragana, + "Katakana" => KeyCode::Katakana, + "F1" => KeyCode::F1, + "F2" => KeyCode::F2, + "F3" => KeyCode::F3, + "F4" => KeyCode::F4, + "F5" => KeyCode::F5, + "F6" => KeyCode::F6, + "F7" => KeyCode::F7, + "F8" => KeyCode::F8, + "F9" => KeyCode::F9, + "F10" => KeyCode::F10, + "F11" => KeyCode::F11, + "F12" => KeyCode::F12, + "F13" => KeyCode::F13, + "F14" => KeyCode::F14, + "F15" => KeyCode::F15, + "F16" => KeyCode::F16, + "F17" => KeyCode::F17, + "F18" => KeyCode::F18, + "F19" => KeyCode::F19, + "F20" => KeyCode::F20, + "F21" => KeyCode::F21, + "F22" => KeyCode::F22, + "F23" => KeyCode::F23, + "F24" => KeyCode::F24, + "F25" => KeyCode::F25, + "F26" => KeyCode::F26, + "F27" => KeyCode::F27, + "F28" => KeyCode::F28, + "F29" => KeyCode::F29, + "F30" => KeyCode::F30, + "F31" => KeyCode::F31, + "F32" => KeyCode::F32, + "F33" => KeyCode::F33, + "F34" => KeyCode::F34, + "F35" => KeyCode::F35, + // TODO: Fix unbounded leak + string @ _ => KeyCode::Unidentified(NativeKeyCode::Web(Box::leak( + String::from(string).into_boxed_str(), + ))), + } + } +} diff --git a/src/platform_impl/web/mod.rs b/src/platform_impl/web/mod.rs index 80d7081f2d..16aad6d466 100644 --- a/src/platform_impl/web/mod.rs +++ b/src/platform_impl/web/mod.rs @@ -25,6 +25,7 @@ mod error; mod event_loop; mod monitor; mod window; +mod keyboard; #[cfg(feature = "web-sys")] #[path = "web_sys/mod.rs"]