use sessionlockev::keyboard::ModifiersState;
/// Converts a `VirtualKeyCode` from [`winit`] to an [`iced`] key code.
///
/// [`winit`]: https://github.com/rust-windowing/winit
/// [`iced`]: https://github.com/iced-rs/iced/tree/0.12
pub fn key(key: sessionlockev::keyboard::Key) -> iced_core::keyboard::Key {
    use iced_core::keyboard;
    use iced_core::keyboard::key::Named;
    use sessionlockev::keyboard::NamedKey;

    match key {
        sessionlockev::keyboard::Key::Character(c) => keyboard::Key::Character(c),
        sessionlockev::keyboard::Key::Named(named_key) => keyboard::Key::Named(match named_key {
            NamedKey::Alt => Named::Alt,
            NamedKey::AltGraph => Named::AltGraph,
            NamedKey::CapsLock => Named::CapsLock,
            NamedKey::Control => Named::Control,
            NamedKey::Fn => Named::Fn,
            NamedKey::FnLock => Named::FnLock,
            NamedKey::NumLock => Named::NumLock,
            NamedKey::ScrollLock => Named::ScrollLock,
            NamedKey::Shift => Named::Shift,
            NamedKey::Symbol => Named::Symbol,
            NamedKey::SymbolLock => Named::SymbolLock,
            NamedKey::Meta => Named::Meta,
            NamedKey::Hyper => Named::Hyper,
            NamedKey::Super => Named::Super,
            NamedKey::Enter => Named::Enter,
            NamedKey::Tab => Named::Tab,
            NamedKey::Space => Named::Space,
            NamedKey::ArrowDown => Named::ArrowDown,
            NamedKey::ArrowLeft => Named::ArrowLeft,
            NamedKey::ArrowRight => Named::ArrowRight,
            NamedKey::ArrowUp => Named::ArrowUp,
            NamedKey::End => Named::End,
            NamedKey::Home => Named::Home,
            NamedKey::PageDown => Named::PageDown,
            NamedKey::PageUp => Named::PageUp,
            NamedKey::Backspace => Named::Backspace,
            NamedKey::Clear => Named::Clear,
            NamedKey::Copy => Named::Copy,
            NamedKey::CrSel => Named::CrSel,
            NamedKey::Cut => Named::Cut,
            NamedKey::Delete => Named::Delete,
            NamedKey::EraseEof => Named::EraseEof,
            NamedKey::ExSel => Named::ExSel,
            NamedKey::Insert => Named::Insert,
            NamedKey::Paste => Named::Paste,
            NamedKey::Redo => Named::Redo,
            NamedKey::Undo => Named::Undo,
            NamedKey::Accept => Named::Accept,
            NamedKey::Again => Named::Again,
            NamedKey::Attn => Named::Attn,
            NamedKey::Cancel => Named::Cancel,
            NamedKey::ContextMenu => Named::ContextMenu,
            NamedKey::Escape => Named::Escape,
            NamedKey::Execute => Named::Execute,
            NamedKey::Find => Named::Find,
            NamedKey::Help => Named::Help,
            NamedKey::Pause => Named::Pause,
            NamedKey::Play => Named::Play,
            NamedKey::Props => Named::Props,
            NamedKey::Select => Named::Select,
            NamedKey::ZoomIn => Named::ZoomIn,
            NamedKey::ZoomOut => Named::ZoomOut,
            NamedKey::BrightnessDown => Named::BrightnessDown,
            NamedKey::BrightnessUp => Named::BrightnessUp,
            NamedKey::Eject => Named::Eject,
            NamedKey::LogOff => Named::LogOff,
            NamedKey::Power => Named::Power,
            NamedKey::PowerOff => Named::PowerOff,
            NamedKey::PrintScreen => Named::PrintScreen,
            NamedKey::Hibernate => Named::Hibernate,
            NamedKey::Standby => Named::Standby,
            NamedKey::WakeUp => Named::WakeUp,
            NamedKey::AllCandidates => Named::AllCandidates,
            NamedKey::Alphanumeric => Named::Alphanumeric,
            NamedKey::CodeInput => Named::CodeInput,
            NamedKey::Compose => Named::Compose,
            NamedKey::Convert => Named::Convert,
            NamedKey::FinalMode => Named::FinalMode,
            NamedKey::GroupFirst => Named::GroupFirst,
            NamedKey::GroupLast => Named::GroupLast,
            NamedKey::GroupNext => Named::GroupNext,
            NamedKey::GroupPrevious => Named::GroupPrevious,
            NamedKey::ModeChange => Named::ModeChange,
            NamedKey::NextCandidate => Named::NextCandidate,
            NamedKey::NonConvert => Named::NonConvert,
            NamedKey::PreviousCandidate => Named::PreviousCandidate,
            NamedKey::Process => Named::Process,
            NamedKey::SingleCandidate => Named::SingleCandidate,
            NamedKey::HangulMode => Named::HangulMode,
            NamedKey::HanjaMode => Named::HanjaMode,
            NamedKey::JunjaMode => Named::JunjaMode,
            NamedKey::Eisu => Named::Eisu,
            NamedKey::Hankaku => Named::Hankaku,
            NamedKey::Hiragana => Named::Hiragana,
            NamedKey::HiraganaKatakana => Named::HiraganaKatakana,
            NamedKey::KanaMode => Named::KanaMode,
            NamedKey::KanjiMode => Named::KanjiMode,
            NamedKey::Katakana => Named::Katakana,
            NamedKey::Romaji => Named::Romaji,
            NamedKey::Zenkaku => Named::Zenkaku,
            NamedKey::ZenkakuHankaku => Named::ZenkakuHankaku,
            NamedKey::Soft1 => Named::Soft1,
            NamedKey::Soft2 => Named::Soft2,
            NamedKey::Soft3 => Named::Soft3,
            NamedKey::Soft4 => Named::Soft4,
            NamedKey::ChannelDown => Named::ChannelDown,
            NamedKey::ChannelUp => Named::ChannelUp,
            NamedKey::Close => Named::Close,
            NamedKey::MailForward => Named::MailForward,
            NamedKey::MailReply => Named::MailReply,
            NamedKey::MailSend => Named::MailSend,
            NamedKey::MediaClose => Named::MediaClose,
            NamedKey::MediaFastForward => Named::MediaFastForward,
            NamedKey::MediaPause => Named::MediaPause,
            NamedKey::MediaPlay => Named::MediaPlay,
            NamedKey::MediaPlayPause => Named::MediaPlayPause,
            NamedKey::MediaRecord => Named::MediaRecord,
            NamedKey::MediaRewind => Named::MediaRewind,
            NamedKey::MediaStop => Named::MediaStop,
            NamedKey::MediaTrackNext => Named::MediaTrackNext,
            NamedKey::MediaTrackPrevious => Named::MediaTrackPrevious,
            NamedKey::New => Named::New,
            NamedKey::Open => Named::Open,
            NamedKey::Print => Named::Print,
            NamedKey::Save => Named::Save,
            NamedKey::SpellCheck => Named::SpellCheck,
            NamedKey::Key11 => Named::Key11,
            NamedKey::Key12 => Named::Key12,
            NamedKey::AudioBalanceLeft => Named::AudioBalanceLeft,
            NamedKey::AudioBalanceRight => Named::AudioBalanceRight,
            NamedKey::AudioBassBoostDown => Named::AudioBassBoostDown,
            NamedKey::AudioBassBoostToggle => Named::AudioBassBoostToggle,
            NamedKey::AudioBassBoostUp => Named::AudioBassBoostUp,
            NamedKey::AudioFaderFront => Named::AudioFaderFront,
            NamedKey::AudioFaderRear => Named::AudioFaderRear,
            NamedKey::AudioSurroundModeNext => Named::AudioSurroundModeNext,
            NamedKey::AudioTrebleDown => Named::AudioTrebleDown,
            NamedKey::AudioTrebleUp => Named::AudioTrebleUp,
            NamedKey::AudioVolumeDown => Named::AudioVolumeDown,
            NamedKey::AudioVolumeUp => Named::AudioVolumeUp,
            NamedKey::AudioVolumeMute => Named::AudioVolumeMute,
            NamedKey::MicrophoneToggle => Named::MicrophoneToggle,
            NamedKey::MicrophoneVolumeDown => Named::MicrophoneVolumeDown,
            NamedKey::MicrophoneVolumeUp => Named::MicrophoneVolumeUp,
            NamedKey::MicrophoneVolumeMute => Named::MicrophoneVolumeMute,
            NamedKey::SpeechCorrectionList => Named::SpeechCorrectionList,
            NamedKey::SpeechInputToggle => Named::SpeechInputToggle,
            NamedKey::LaunchApplication1 => Named::LaunchApplication1,
            NamedKey::LaunchApplication2 => Named::LaunchApplication2,
            NamedKey::LaunchCalendar => Named::LaunchCalendar,
            NamedKey::LaunchContacts => Named::LaunchContacts,
            NamedKey::LaunchMail => Named::LaunchMail,
            NamedKey::LaunchMediaPlayer => Named::LaunchMediaPlayer,
            NamedKey::LaunchMusicPlayer => Named::LaunchMusicPlayer,
            NamedKey::LaunchPhone => Named::LaunchPhone,
            NamedKey::LaunchScreenSaver => Named::LaunchScreenSaver,
            NamedKey::LaunchSpreadsheet => Named::LaunchSpreadsheet,
            NamedKey::LaunchWebBrowser => Named::LaunchWebBrowser,
            NamedKey::LaunchWebCam => Named::LaunchWebCam,
            NamedKey::LaunchWordProcessor => Named::LaunchWordProcessor,
            NamedKey::BrowserBack => Named::BrowserBack,
            NamedKey::BrowserFavorites => Named::BrowserFavorites,
            NamedKey::BrowserForward => Named::BrowserForward,
            NamedKey::BrowserHome => Named::BrowserHome,
            NamedKey::BrowserRefresh => Named::BrowserRefresh,
            NamedKey::BrowserSearch => Named::BrowserSearch,
            NamedKey::BrowserStop => Named::BrowserStop,
            NamedKey::AppSwitch => Named::AppSwitch,
            NamedKey::Call => Named::Call,
            NamedKey::Camera => Named::Camera,
            NamedKey::CameraFocus => Named::CameraFocus,
            NamedKey::EndCall => Named::EndCall,
            NamedKey::GoBack => Named::GoBack,
            NamedKey::GoHome => Named::GoHome,
            NamedKey::HeadsetHook => Named::HeadsetHook,
            NamedKey::LastNumberRedial => Named::LastNumberRedial,
            NamedKey::Notification => Named::Notification,
            NamedKey::MannerMode => Named::MannerMode,
            NamedKey::VoiceDial => Named::VoiceDial,
            NamedKey::TV => Named::TV,
            NamedKey::TV3DMode => Named::TV3DMode,
            NamedKey::TVAntennaCable => Named::TVAntennaCable,
            NamedKey::TVAudioDescription => Named::TVAudioDescription,
            NamedKey::TVAudioDescriptionMixDown => Named::TVAudioDescriptionMixDown,
            NamedKey::TVAudioDescriptionMixUp => Named::TVAudioDescriptionMixUp,
            NamedKey::TVContentsMenu => Named::TVContentsMenu,
            NamedKey::TVDataService => Named::TVDataService,
            NamedKey::TVInput => Named::TVInput,
            NamedKey::TVInputComponent1 => Named::TVInputComponent1,
            NamedKey::TVInputComponent2 => Named::TVInputComponent2,
            NamedKey::TVInputComposite1 => Named::TVInputComposite1,
            NamedKey::TVInputComposite2 => Named::TVInputComposite2,
            NamedKey::TVInputHDMI1 => Named::TVInputHDMI1,
            NamedKey::TVInputHDMI2 => Named::TVInputHDMI2,
            NamedKey::TVInputHDMI3 => Named::TVInputHDMI3,
            NamedKey::TVInputHDMI4 => Named::TVInputHDMI4,
            NamedKey::TVInputVGA1 => Named::TVInputVGA1,
            NamedKey::TVMediaContext => Named::TVMediaContext,
            NamedKey::TVNetwork => Named::TVNetwork,
            NamedKey::TVNumberEntry => Named::TVNumberEntry,
            NamedKey::TVPower => Named::TVPower,
            NamedKey::TVRadioService => Named::TVRadioService,
            NamedKey::TVSatellite => Named::TVSatellite,
            NamedKey::TVSatelliteBS => Named::TVSatelliteBS,
            NamedKey::TVSatelliteCS => Named::TVSatelliteCS,
            NamedKey::TVSatelliteToggle => Named::TVSatelliteToggle,
            NamedKey::TVTerrestrialAnalog => Named::TVTerrestrialAnalog,
            NamedKey::TVTerrestrialDigital => Named::TVTerrestrialDigital,
            NamedKey::TVTimer => Named::TVTimer,
            NamedKey::AVRInput => Named::AVRInput,
            NamedKey::AVRPower => Named::AVRPower,
            NamedKey::ColorF0Red => Named::ColorF0Red,
            NamedKey::ColorF1Green => Named::ColorF1Green,
            NamedKey::ColorF2Yellow => Named::ColorF2Yellow,
            NamedKey::ColorF3Blue => Named::ColorF3Blue,
            NamedKey::ColorF4Grey => Named::ColorF4Grey,
            NamedKey::ColorF5Brown => Named::ColorF5Brown,
            NamedKey::ClosedCaptionToggle => Named::ClosedCaptionToggle,
            NamedKey::Dimmer => Named::Dimmer,
            NamedKey::DisplaySwap => Named::DisplaySwap,
            NamedKey::DVR => Named::DVR,
            NamedKey::Exit => Named::Exit,
            NamedKey::FavoriteClear0 => Named::FavoriteClear0,
            NamedKey::FavoriteClear1 => Named::FavoriteClear1,
            NamedKey::FavoriteClear2 => Named::FavoriteClear2,
            NamedKey::FavoriteClear3 => Named::FavoriteClear3,
            NamedKey::FavoriteRecall0 => Named::FavoriteRecall0,
            NamedKey::FavoriteRecall1 => Named::FavoriteRecall1,
            NamedKey::FavoriteRecall2 => Named::FavoriteRecall2,
            NamedKey::FavoriteRecall3 => Named::FavoriteRecall3,
            NamedKey::FavoriteStore0 => Named::FavoriteStore0,
            NamedKey::FavoriteStore1 => Named::FavoriteStore1,
            NamedKey::FavoriteStore2 => Named::FavoriteStore2,
            NamedKey::FavoriteStore3 => Named::FavoriteStore3,
            NamedKey::Guide => Named::Guide,
            NamedKey::GuideNextDay => Named::GuideNextDay,
            NamedKey::GuidePreviousDay => Named::GuidePreviousDay,
            NamedKey::Info => Named::Info,
            NamedKey::InstantReplay => Named::InstantReplay,
            NamedKey::Link => Named::Link,
            NamedKey::ListProgram => Named::ListProgram,
            NamedKey::LiveContent => Named::LiveContent,
            NamedKey::Lock => Named::Lock,
            NamedKey::MediaApps => Named::MediaApps,
            NamedKey::MediaAudioTrack => Named::MediaAudioTrack,
            NamedKey::MediaLast => Named::MediaLast,
            NamedKey::MediaSkipBackward => Named::MediaSkipBackward,
            NamedKey::MediaSkipForward => Named::MediaSkipForward,
            NamedKey::MediaStepBackward => Named::MediaStepBackward,
            NamedKey::MediaStepForward => Named::MediaStepForward,
            NamedKey::MediaTopMenu => Named::MediaTopMenu,
            NamedKey::NavigateIn => Named::NavigateIn,
            NamedKey::NavigateNext => Named::NavigateNext,
            NamedKey::NavigateOut => Named::NavigateOut,
            NamedKey::NavigatePrevious => Named::NavigatePrevious,
            NamedKey::NextFavoriteChannel => Named::NextFavoriteChannel,
            NamedKey::NextUserProfile => Named::NextUserProfile,
            NamedKey::OnDemand => Named::OnDemand,
            NamedKey::Pairing => Named::Pairing,
            NamedKey::PinPDown => Named::PinPDown,
            NamedKey::PinPMove => Named::PinPMove,
            NamedKey::PinPToggle => Named::PinPToggle,
            NamedKey::PinPUp => Named::PinPUp,
            NamedKey::PlaySpeedDown => Named::PlaySpeedDown,
            NamedKey::PlaySpeedReset => Named::PlaySpeedReset,
            NamedKey::PlaySpeedUp => Named::PlaySpeedUp,
            NamedKey::RandomToggle => Named::RandomToggle,
            NamedKey::RcLowBattery => Named::RcLowBattery,
            NamedKey::RecordSpeedNext => Named::RecordSpeedNext,
            NamedKey::RfBypass => Named::RfBypass,
            NamedKey::ScanChannelsToggle => Named::ScanChannelsToggle,
            NamedKey::ScreenModeNext => Named::ScreenModeNext,
            NamedKey::Settings => Named::Settings,
            NamedKey::SplitScreenToggle => Named::SplitScreenToggle,
            NamedKey::STBInput => Named::STBInput,
            NamedKey::STBPower => Named::STBPower,
            NamedKey::Subtitle => Named::Subtitle,
            NamedKey::Teletext => Named::Teletext,
            NamedKey::VideoModeNext => Named::VideoModeNext,
            NamedKey::Wink => Named::Wink,
            NamedKey::ZoomToggle => Named::ZoomToggle,
            NamedKey::F1 => Named::F1,
            NamedKey::F2 => Named::F2,
            NamedKey::F3 => Named::F3,
            NamedKey::F4 => Named::F4,
            NamedKey::F5 => Named::F5,
            NamedKey::F6 => Named::F6,
            NamedKey::F7 => Named::F7,
            NamedKey::F8 => Named::F8,
            NamedKey::F9 => Named::F9,
            NamedKey::F10 => Named::F10,
            NamedKey::F11 => Named::F11,
            NamedKey::F12 => Named::F12,
            NamedKey::F13 => Named::F13,
            NamedKey::F14 => Named::F14,
            NamedKey::F15 => Named::F15,
            NamedKey::F16 => Named::F16,
            NamedKey::F17 => Named::F17,
            NamedKey::F18 => Named::F18,
            NamedKey::F19 => Named::F19,
            NamedKey::F20 => Named::F20,
            NamedKey::F21 => Named::F21,
            NamedKey::F22 => Named::F22,
            NamedKey::F23 => Named::F23,
            NamedKey::F24 => Named::F24,
            NamedKey::F25 => Named::F25,
            NamedKey::F26 => Named::F26,
            NamedKey::F27 => Named::F27,
            NamedKey::F28 => Named::F28,
            NamedKey::F29 => Named::F29,
            NamedKey::F30 => Named::F30,
            NamedKey::F31 => Named::F31,
            NamedKey::F32 => Named::F32,
            NamedKey::F33 => Named::F33,
            NamedKey::F34 => Named::F34,
            NamedKey::F35 => Named::F35,
            _ => return keyboard::Key::Unidentified,
        }),
        _ => keyboard::Key::Unidentified,
    }
}

pub fn modifiers(modifiers: ModifiersState) -> iced_core::keyboard::Modifiers {
    use iced_core::keyboard;
    let mut result = keyboard::Modifiers::empty();

    result.set(keyboard::Modifiers::SHIFT, modifiers.shift_key());
    result.set(keyboard::Modifiers::CTRL, modifiers.control_key());
    result.set(keyboard::Modifiers::ALT, modifiers.alt_key());
    result.set(keyboard::Modifiers::LOGO, modifiers.super_key());

    result
}

pub fn physical_key(
    physical_key: sessionlockev::keyboard::PhysicalKey,
) -> iced_core::keyboard::key::Physical {
    use iced_core::keyboard;
    match physical_key {
        sessionlockev::keyboard::PhysicalKey::Code(code) => {
            key_code(code).map(keyboard::key::Physical::Code).unwrap_or(
                keyboard::key::Physical::Unidentified(keyboard::key::NativeCode::Unidentified),
            )
        }
        sessionlockev::keyboard::PhysicalKey::Unidentified(code) => {
            keyboard::key::Physical::Unidentified(native_key_code(code))
        }
    }
}

use iced_core::keyboard;
/// Converts a `KeyCode` from [`winit`] to an [`iced`] key code.
///
/// [`winit`]: https://github.com/rust-windowing/winit
/// [`iced`]: https://github.com/iced-rs/iced/tree/0.12
pub fn key_code(key_code: sessionlockev::keyboard::KeyCode) -> Option<keyboard::key::Code> {
    use sessionlockev::keyboard::KeyCode;

    Some(match key_code {
        KeyCode::Backquote => keyboard::key::Code::Backquote,
        KeyCode::Backslash => keyboard::key::Code::Backslash,
        KeyCode::BracketLeft => keyboard::key::Code::BracketLeft,
        KeyCode::BracketRight => keyboard::key::Code::BracketRight,
        KeyCode::Comma => keyboard::key::Code::Comma,
        KeyCode::Digit0 => keyboard::key::Code::Digit0,
        KeyCode::Digit1 => keyboard::key::Code::Digit1,
        KeyCode::Digit2 => keyboard::key::Code::Digit2,
        KeyCode::Digit3 => keyboard::key::Code::Digit3,
        KeyCode::Digit4 => keyboard::key::Code::Digit4,
        KeyCode::Digit5 => keyboard::key::Code::Digit5,
        KeyCode::Digit6 => keyboard::key::Code::Digit6,
        KeyCode::Digit7 => keyboard::key::Code::Digit7,
        KeyCode::Digit8 => keyboard::key::Code::Digit8,
        KeyCode::Digit9 => keyboard::key::Code::Digit9,
        KeyCode::Equal => keyboard::key::Code::Equal,
        KeyCode::IntlBackslash => keyboard::key::Code::IntlBackslash,
        KeyCode::IntlRo => keyboard::key::Code::IntlRo,
        KeyCode::IntlYen => keyboard::key::Code::IntlYen,
        KeyCode::KeyA => keyboard::key::Code::KeyA,
        KeyCode::KeyB => keyboard::key::Code::KeyB,
        KeyCode::KeyC => keyboard::key::Code::KeyC,
        KeyCode::KeyD => keyboard::key::Code::KeyD,
        KeyCode::KeyE => keyboard::key::Code::KeyE,
        KeyCode::KeyF => keyboard::key::Code::KeyF,
        KeyCode::KeyG => keyboard::key::Code::KeyG,
        KeyCode::KeyH => keyboard::key::Code::KeyH,
        KeyCode::KeyI => keyboard::key::Code::KeyI,
        KeyCode::KeyJ => keyboard::key::Code::KeyJ,
        KeyCode::KeyK => keyboard::key::Code::KeyK,
        KeyCode::KeyL => keyboard::key::Code::KeyL,
        KeyCode::KeyM => keyboard::key::Code::KeyM,
        KeyCode::KeyN => keyboard::key::Code::KeyN,
        KeyCode::KeyO => keyboard::key::Code::KeyO,
        KeyCode::KeyP => keyboard::key::Code::KeyP,
        KeyCode::KeyQ => keyboard::key::Code::KeyQ,
        KeyCode::KeyR => keyboard::key::Code::KeyR,
        KeyCode::KeyS => keyboard::key::Code::KeyS,
        KeyCode::KeyT => keyboard::key::Code::KeyT,
        KeyCode::KeyU => keyboard::key::Code::KeyU,
        KeyCode::KeyV => keyboard::key::Code::KeyV,
        KeyCode::KeyW => keyboard::key::Code::KeyW,
        KeyCode::KeyX => keyboard::key::Code::KeyX,
        KeyCode::KeyY => keyboard::key::Code::KeyY,
        KeyCode::KeyZ => keyboard::key::Code::KeyZ,
        KeyCode::Minus => keyboard::key::Code::Minus,
        KeyCode::Period => keyboard::key::Code::Period,
        KeyCode::Quote => keyboard::key::Code::Quote,
        KeyCode::Semicolon => keyboard::key::Code::Semicolon,
        KeyCode::Slash => keyboard::key::Code::Slash,
        KeyCode::AltLeft => keyboard::key::Code::AltLeft,
        KeyCode::AltRight => keyboard::key::Code::AltRight,
        KeyCode::Backspace => keyboard::key::Code::Backspace,
        KeyCode::CapsLock => keyboard::key::Code::CapsLock,
        KeyCode::ContextMenu => keyboard::key::Code::ContextMenu,
        KeyCode::ControlLeft => keyboard::key::Code::ControlLeft,
        KeyCode::ControlRight => keyboard::key::Code::ControlRight,
        KeyCode::Enter => keyboard::key::Code::Enter,
        KeyCode::SuperLeft => keyboard::key::Code::SuperLeft,
        KeyCode::SuperRight => keyboard::key::Code::SuperRight,
        KeyCode::ShiftLeft => keyboard::key::Code::ShiftLeft,
        KeyCode::ShiftRight => keyboard::key::Code::ShiftRight,
        KeyCode::Space => keyboard::key::Code::Space,
        KeyCode::Tab => keyboard::key::Code::Tab,
        KeyCode::Convert => keyboard::key::Code::Convert,
        KeyCode::KanaMode => keyboard::key::Code::KanaMode,
        KeyCode::Lang1 => keyboard::key::Code::Lang1,
        KeyCode::Lang2 => keyboard::key::Code::Lang2,
        KeyCode::Lang3 => keyboard::key::Code::Lang3,
        KeyCode::Lang4 => keyboard::key::Code::Lang4,
        KeyCode::Lang5 => keyboard::key::Code::Lang5,
        KeyCode::NonConvert => keyboard::key::Code::NonConvert,
        KeyCode::Delete => keyboard::key::Code::Delete,
        KeyCode::End => keyboard::key::Code::End,
        KeyCode::Help => keyboard::key::Code::Help,
        KeyCode::Home => keyboard::key::Code::Home,
        KeyCode::Insert => keyboard::key::Code::Insert,
        KeyCode::PageDown => keyboard::key::Code::PageDown,
        KeyCode::PageUp => keyboard::key::Code::PageUp,
        KeyCode::ArrowDown => keyboard::key::Code::ArrowDown,
        KeyCode::ArrowLeft => keyboard::key::Code::ArrowLeft,
        KeyCode::ArrowRight => keyboard::key::Code::ArrowRight,
        KeyCode::ArrowUp => keyboard::key::Code::ArrowUp,
        KeyCode::NumLock => keyboard::key::Code::NumLock,
        KeyCode::Numpad0 => keyboard::key::Code::Numpad0,
        KeyCode::Numpad1 => keyboard::key::Code::Numpad1,
        KeyCode::Numpad2 => keyboard::key::Code::Numpad2,
        KeyCode::Numpad3 => keyboard::key::Code::Numpad3,
        KeyCode::Numpad4 => keyboard::key::Code::Numpad4,
        KeyCode::Numpad5 => keyboard::key::Code::Numpad5,
        KeyCode::Numpad6 => keyboard::key::Code::Numpad6,
        KeyCode::Numpad7 => keyboard::key::Code::Numpad7,
        KeyCode::Numpad8 => keyboard::key::Code::Numpad8,
        KeyCode::Numpad9 => keyboard::key::Code::Numpad9,
        KeyCode::NumpadAdd => keyboard::key::Code::NumpadAdd,
        KeyCode::NumpadBackspace => keyboard::key::Code::NumpadBackspace,
        KeyCode::NumpadClear => keyboard::key::Code::NumpadClear,
        KeyCode::NumpadClearEntry => keyboard::key::Code::NumpadClearEntry,
        KeyCode::NumpadComma => keyboard::key::Code::NumpadComma,
        KeyCode::NumpadDecimal => keyboard::key::Code::NumpadDecimal,
        KeyCode::NumpadDivide => keyboard::key::Code::NumpadDivide,
        KeyCode::NumpadEnter => keyboard::key::Code::NumpadEnter,
        KeyCode::NumpadEqual => keyboard::key::Code::NumpadEqual,
        KeyCode::NumpadHash => keyboard::key::Code::NumpadHash,
        KeyCode::NumpadMemoryAdd => keyboard::key::Code::NumpadMemoryAdd,
        KeyCode::NumpadMemoryClear => keyboard::key::Code::NumpadMemoryClear,
        KeyCode::NumpadMemoryRecall => keyboard::key::Code::NumpadMemoryRecall,
        KeyCode::NumpadMemoryStore => keyboard::key::Code::NumpadMemoryStore,
        KeyCode::NumpadMemorySubtract => keyboard::key::Code::NumpadMemorySubtract,
        KeyCode::NumpadMultiply => keyboard::key::Code::NumpadMultiply,
        KeyCode::NumpadParenLeft => keyboard::key::Code::NumpadParenLeft,
        KeyCode::NumpadParenRight => keyboard::key::Code::NumpadParenRight,
        KeyCode::NumpadStar => keyboard::key::Code::NumpadStar,
        KeyCode::NumpadSubtract => keyboard::key::Code::NumpadSubtract,
        KeyCode::Escape => keyboard::key::Code::Escape,
        KeyCode::Fn => keyboard::key::Code::Fn,
        KeyCode::FnLock => keyboard::key::Code::FnLock,
        KeyCode::PrintScreen => keyboard::key::Code::PrintScreen,
        KeyCode::ScrollLock => keyboard::key::Code::ScrollLock,
        KeyCode::Pause => keyboard::key::Code::Pause,
        KeyCode::BrowserBack => keyboard::key::Code::BrowserBack,
        KeyCode::BrowserFavorites => keyboard::key::Code::BrowserFavorites,
        KeyCode::BrowserForward => keyboard::key::Code::BrowserForward,
        KeyCode::BrowserHome => keyboard::key::Code::BrowserHome,
        KeyCode::BrowserRefresh => keyboard::key::Code::BrowserRefresh,
        KeyCode::BrowserSearch => keyboard::key::Code::BrowserSearch,
        KeyCode::BrowserStop => keyboard::key::Code::BrowserStop,
        KeyCode::Eject => keyboard::key::Code::Eject,
        KeyCode::LaunchApp1 => keyboard::key::Code::LaunchApp1,
        KeyCode::LaunchApp2 => keyboard::key::Code::LaunchApp2,
        KeyCode::LaunchMail => keyboard::key::Code::LaunchMail,
        KeyCode::MediaPlayPause => keyboard::key::Code::MediaPlayPause,
        KeyCode::MediaSelect => keyboard::key::Code::MediaSelect,
        KeyCode::MediaStop => keyboard::key::Code::MediaStop,
        KeyCode::MediaTrackNext => keyboard::key::Code::MediaTrackNext,
        KeyCode::MediaTrackPrevious => keyboard::key::Code::MediaTrackPrevious,
        KeyCode::Power => keyboard::key::Code::Power,
        KeyCode::Sleep => keyboard::key::Code::Sleep,
        KeyCode::AudioVolumeDown => keyboard::key::Code::AudioVolumeDown,
        KeyCode::AudioVolumeMute => keyboard::key::Code::AudioVolumeMute,
        KeyCode::AudioVolumeUp => keyboard::key::Code::AudioVolumeUp,
        KeyCode::WakeUp => keyboard::key::Code::WakeUp,
        KeyCode::Meta => keyboard::key::Code::Meta,
        KeyCode::Hyper => keyboard::key::Code::Hyper,
        KeyCode::Turbo => keyboard::key::Code::Turbo,
        KeyCode::Abort => keyboard::key::Code::Abort,
        KeyCode::Resume => keyboard::key::Code::Resume,
        KeyCode::Suspend => keyboard::key::Code::Suspend,
        KeyCode::Again => keyboard::key::Code::Again,
        KeyCode::Copy => keyboard::key::Code::Copy,
        KeyCode::Cut => keyboard::key::Code::Cut,
        KeyCode::Find => keyboard::key::Code::Find,
        KeyCode::Open => keyboard::key::Code::Open,
        KeyCode::Paste => keyboard::key::Code::Paste,
        KeyCode::Props => keyboard::key::Code::Props,
        KeyCode::Select => keyboard::key::Code::Select,
        KeyCode::Undo => keyboard::key::Code::Undo,
        KeyCode::Hiragana => keyboard::key::Code::Hiragana,
        KeyCode::Katakana => keyboard::key::Code::Katakana,
        KeyCode::F1 => keyboard::key::Code::F1,
        KeyCode::F2 => keyboard::key::Code::F2,
        KeyCode::F3 => keyboard::key::Code::F3,
        KeyCode::F4 => keyboard::key::Code::F4,
        KeyCode::F5 => keyboard::key::Code::F5,
        KeyCode::F6 => keyboard::key::Code::F6,
        KeyCode::F7 => keyboard::key::Code::F7,
        KeyCode::F8 => keyboard::key::Code::F8,
        KeyCode::F9 => keyboard::key::Code::F9,
        KeyCode::F10 => keyboard::key::Code::F10,
        KeyCode::F11 => keyboard::key::Code::F11,
        KeyCode::F12 => keyboard::key::Code::F12,
        KeyCode::F13 => keyboard::key::Code::F13,
        KeyCode::F14 => keyboard::key::Code::F14,
        KeyCode::F15 => keyboard::key::Code::F15,
        KeyCode::F16 => keyboard::key::Code::F16,
        KeyCode::F17 => keyboard::key::Code::F17,
        KeyCode::F18 => keyboard::key::Code::F18,
        KeyCode::F19 => keyboard::key::Code::F19,
        KeyCode::F20 => keyboard::key::Code::F20,
        KeyCode::F21 => keyboard::key::Code::F21,
        KeyCode::F22 => keyboard::key::Code::F22,
        KeyCode::F23 => keyboard::key::Code::F23,
        KeyCode::F24 => keyboard::key::Code::F24,
        KeyCode::F25 => keyboard::key::Code::F25,
        KeyCode::F26 => keyboard::key::Code::F26,
        KeyCode::F27 => keyboard::key::Code::F27,
        KeyCode::F28 => keyboard::key::Code::F28,
        KeyCode::F29 => keyboard::key::Code::F29,
        KeyCode::F30 => keyboard::key::Code::F30,
        KeyCode::F31 => keyboard::key::Code::F31,
        KeyCode::F32 => keyboard::key::Code::F32,
        KeyCode::F33 => keyboard::key::Code::F33,
        KeyCode::F34 => keyboard::key::Code::F34,
        KeyCode::F35 => keyboard::key::Code::F35,
        _ => None?,
    })
}

/// Converts a `NativeKeyCode` from [`winit`] to an [`iced`] native key code.
///
/// [`winit`]: https://github.com/rust-windowing/winit
/// [`iced`]: https://github.com/iced-rs/iced/tree/0.12
pub fn native_key_code(
    native_key_code: sessionlockev::keyboard::NativeKeyCode,
) -> keyboard::key::NativeCode {
    use sessionlockev::keyboard::NativeKeyCode;

    match native_key_code {
        NativeKeyCode::Unidentified => keyboard::key::NativeCode::Unidentified,
        NativeKeyCode::Android(code) => keyboard::key::NativeCode::Android(code),
        NativeKeyCode::MacOS(code) => keyboard::key::NativeCode::MacOS(code),
        NativeKeyCode::Windows(code) => keyboard::key::NativeCode::Windows(code),
        NativeKeyCode::Xkb(code) => keyboard::key::NativeCode::Xkb(code),
    }
}
