fn code_to_key(code: Code) -> Option<KbKey> {
    Some(match code {
        Code::Escape => KbKey::Escape,
        Code::ShiftLeft | Code::ShiftRight => KbKey::Shift,
        Code::AltLeft | Code::AltRight => KbKey::Alt,
        Code::MetaLeft | Code::MetaRight => KbKey::Meta,
        Code::ControlLeft | Code::ControlRight => KbKey::Control,
        Code::CapsLock => KbKey::CapsLock,
        // kVK_ANSI_KeypadClear
        Code::NumLock => KbKey::Clear,
        Code::Fn => KbKey::Fn,
        Code::F1 => KbKey::F1,
        Code::F2 => KbKey::F2,
        Code::F3 => KbKey::F3,
        Code::F4 => KbKey::F4,
        Code::F5 => KbKey::F5,
        Code::F6 => KbKey::F6,
        Code::F7 => KbKey::F7,
        Code::F8 => KbKey::F8,
        Code::F9 => KbKey::F9,
        Code::F10 => KbKey::F10,
        Code::F11 => KbKey::F11,
        Code::F12 => KbKey::F12,
        Code::F13 => KbKey::F13,
        Code::F14 => KbKey::F14,
        Code::F15 => KbKey::F15,
        Code::F16 => KbKey::F16,
        Code::F17 => KbKey::F17,
        Code::F18 => KbKey::F18,
        Code::F19 => KbKey::F19,
        Code::F20 => KbKey::F20,
        Code::F21 => KbKey::F21,
        Code::F22 => KbKey::F22,
        Code::F23 => KbKey::F23,
        Code::F24 => KbKey::F24,
        Code::Pause => KbKey::Pause,
        Code::ScrollLock => KbKey::ScrollLock,
        Code::PrintScreen => KbKey::PrintScreen,
        Code::Insert => KbKey::Insert,
        Code::Delete => KbKey::Delete,
        Code::Tab => KbKey::Tab,
        Code::Backspace => KbKey::Backspace,
        Code::ContextMenu => KbKey::ContextMenu,
        // kVK_JIS_Kana
        Code::Lang1 => KbKey::KanjiMode,
        // kVK_JIS_Eisu
        Code::Lang2 => KbKey::Eisu,
        Code::Home => KbKey::Home,
        Code::End => KbKey::End,
        Code::PageUp => KbKey::PageUp,
        Code::PageDown => KbKey::PageDown,
        Code::ArrowLeft => KbKey::ArrowLeft,
        Code::ArrowRight => KbKey::ArrowRight,
        Code::ArrowUp => KbKey::ArrowUp,
        Code::ArrowDown => KbKey::ArrowDown,
        Code::Enter => KbKey::Enter,
        Code::NumpadEnter => KbKey::Enter,
        Code::Help => KbKey::Help,
        _ => return None,
    })
}
/// Convert code to key.
///
/// On macOS, for non-printable keys, the keyCode we get from the event serves is
/// really more of a key than a physical scan code.
///
/// When this function returns None, the code can be considered printable.
///
/// The logic for this function is derived from KEY_MAP_COCOA bindings in
/// NativeKeyToDOMKeyName.h.
Convert code to key.
On macOS, for non-printable keys, the keyCode we get from the event serves is
really more of a key than a physical scan code.

When this function returns None, the code can be considered printable.

The logic for this function is derived from KEY_MAP_COCOA bindings in
NativeKeyToDOMKeyName.h.
Convert code to key . On macOS for non - printable keys the keyCode we get from the event serves is really more of a key than a physical scan code . When this function returns None the code can be considered printable . The logic for this function is derived from KEY_MAP_COCOA bindings in NativeKeyToDOMKeyName . h .
fn code_to_key(code: Code) -> Option<KbKey> {
    Some(match code {
        Code::Escape => KbKey::Escape,
        Code::ShiftLeft | Code::ShiftRight => KbKey::Shift,
        Code::AltLeft | Code::AltRight => KbKey::Alt,
        Code::MetaLeft | Code::MetaRight => KbKey::Meta,
        Code::ControlLeft | Code::ControlRight => KbKey::Control,
        Code::CapsLock => KbKey::CapsLock,
        // kVK_ANSI_KeypadClear
        Code::NumLock => KbKey::Clear,
        Code::Fn => KbKey::Fn,
        Code::F1 => KbKey::F1,
        Code::F2 => KbKey::F2,
        Code::F3 => KbKey::F3,
        Code::F4 => KbKey::F4,
        Code::F5 => KbKey::F5,
        Code::F6 => KbKey::F6,
        Code::F7 => KbKey::F7,
        Code::F8 => KbKey::F8,
        Code::F9 => KbKey::F9,
        Code::F10 => KbKey::F10,
        Code::F11 => KbKey::F11,
        Code::F12 => KbKey::F12,
        Code::F13 => KbKey::F13,
        Code::F14 => KbKey::F14,
        Code::F15 => KbKey::F15,
        Code::F16 => KbKey::F16,
        Code::F17 => KbKey::F17,
        Code::F18 => KbKey::F18,
        Code::F19 => KbKey::F19,
        Code::F20 => KbKey::F20,
        Code::F21 => KbKey::F21,
        Code::F22 => KbKey::F22,
        Code::F23 => KbKey::F23,
        Code::F24 => KbKey::F24,
        Code::Pause => KbKey::Pause,
        Code::ScrollLock => KbKey::ScrollLock,
        Code::PrintScreen => KbKey::PrintScreen,
        Code::Insert => KbKey::Insert,
        Code::Delete => KbKey::Delete,
        Code::Tab => KbKey::Tab,
        Code::Backspace => KbKey::Backspace,
        Code::ContextMenu => KbKey::ContextMenu,
        // kVK_JIS_Kana
        Code::Lang1 => KbKey::KanjiMode,
        // kVK_JIS_Eisu
        Code::Lang2 => KbKey::Eisu,
        Code::Home => KbKey::Home,
        Code::End => KbKey::End,
        Code::PageUp => KbKey::PageUp,
        Code::PageDown => KbKey::PageDown,
        Code::ArrowLeft => KbKey::ArrowLeft,
        Code::ArrowRight => KbKey::ArrowRight,
        Code::ArrowUp => KbKey::ArrowUp,
        Code::ArrowDown => KbKey::ArrowDown,
        Code::Enter => KbKey::Enter,
        Code::NumpadEnter => KbKey::Enter,
        Code::Help => KbKey::Help,
        _ => return None,
    })
}
fn code_to_key ( code : Code ) -> Option < KbKey > { Some ( match code { Code :: Escape => KbKey :: Escape , Code :: ShiftLeft | Code :: ShiftRight => KbKey :: Shift , Code :: AltLeft | Code :: AltRight => KbKey :: Alt , Code :: MetaLeft | Code :: MetaRight => KbKey :: Meta , Code :: ControlLeft | Code :: ControlRight => KbKey :: Control , Code :: CapsLock => KbKey :: CapsLock , // kVK_ANSI_KeypadClear Code :: NumLock => KbKey :: Clear , Code :: Fn => KbKey :: Fn , Code :: F1 => KbKey :: F1 , Code :: F2 => KbKey :: F2 , Code :: F3 => KbKey :: F3 , Code :: F4 => KbKey :: F4 , Code :: F5 => KbKey :: F5 , Code :: F6 => KbKey :: F6 , Code :: F7 => KbKey :: F7 , Code :: F8 => KbKey :: F8 , Code :: F9 => KbKey :: F9 , Code :: F10 => KbKey :: F10 , Code :: F11 => KbKey :: F11 , Code :: F12 => KbKey :: F12 , Code :: F13 => KbKey :: F13 , Code :: F14 => KbKey :: F14 , Code :: F15 => KbKey :: F15 , Code :: F16 => KbKey :: F16 , Code :: F17 => KbKey :: F17 , Code :: F18 => KbKey :: F18 , Code :: F19 => KbKey :: F19 , Code :: F20 => KbKey :: F20 , Code :: F21 => KbKey :: F21 , Code :: F22 => KbKey :: F22 , Code :: F23 => KbKey :: F23 , Code :: F24 => KbKey :: F24 , Code :: Pause => KbKey :: Pause , Code :: ScrollLock => KbKey :: ScrollLock , Code :: PrintScreen => KbKey :: PrintScreen , Code :: Insert => KbKey :: Insert , Code :: Delete => KbKey :: Delete , Code :: Tab => KbKey :: Tab , Code :: Backspace => KbKey :: Backspace , Code :: ContextMenu => KbKey :: ContextMenu , // kVK_JIS_Kana Code :: Lang1 => KbKey :: KanjiMode , // kVK_JIS_Eisu Code :: Lang2 => KbKey :: Eisu , Code :: Home => KbKey :: Home , Code :: End => KbKey :: End , Code :: PageUp => KbKey :: PageUp , Code :: PageDown => KbKey :: PageDown , Code :: ArrowLeft => KbKey :: ArrowLeft , Code :: ArrowRight => KbKey :: ArrowRight , Code :: ArrowUp => KbKey :: ArrowUp , Code :: ArrowDown => KbKey :: ArrowDown , Code :: Enter => KbKey :: Enter , Code :: NumpadEnter => KbKey :: Enter , Code :: Help => KbKey :: Help , _ => return None , } ) }
Convert code to key.
Convert code to key .
code
Code
code
Code