pub fn string_to_key(key_name: &str) -> KeyCode {
    match key_name {
        "0" => KeyCode::K0,
        "1" => KeyCode::K1,
        "2" => KeyCode::K2,
        "3" => KeyCode::K3,
        "4" => KeyCode::K4,
        "5" => KeyCode::K5,
        "6" => KeyCode::K6,
        "7" => KeyCode::K7,
        "8" => KeyCode::K8,
        "9" => KeyCode::K9,
        "A" => KeyCode::KA,
        "B" => KeyCode::KB,
        "C" => KeyCode::KC,
        "D" => KeyCode::KD,
        "E" => KeyCode::KE,
        "F" => KeyCode::KF,
        "G" => KeyCode::KG,
        "H" => KeyCode::KH,
        "I" => KeyCode::KI,
        "J" => KeyCode::KJ,
        "K" => KeyCode::KK,
        "L" => KeyCode::KL,
        "M" => KeyCode::KM,
        "N" => KeyCode::KN,
        "O" => KeyCode::KO,
        "P" => KeyCode::KP,
        "Q" => KeyCode::KQ,
        "R" => KeyCode::KR,
        "S" => KeyCode::KS,
        "T" => KeyCode::KT,
        "U" => KeyCode::KU,
        "V" => KeyCode::KV,
        "W" => KeyCode::KW,
        "X" => KeyCode::KX,
        "Y" => KeyCode::KY,
        "Z" => KeyCode::KZ,
        "F1" => KeyCode::KF1,
        "F2" => KeyCode::KF2,
        "F3" => KeyCode::KF3,
        "F4" => KeyCode::KF4,
        "F5" => KeyCode::KF5,
        "F6" => KeyCode::KF6,
        "F7" => KeyCode::KF7,
        "F8" => KeyCode::KF8,
        "F9" => KeyCode::KF9,
        "F10" => KeyCode::KF10,
        "F11" => KeyCode::KF11,
        "F12" => KeyCode::KF12,
        "Back Space" => KeyCode::KBackspace,
        "Tab" => KeyCode::KTab,
        "Enter" => KeyCode::KEnter,
        "Shift" => KeyCode::KShift,
        "Ctrl" => KeyCode::KCtrl,
        "Alt" => KeyCode::KAlt,
        "Caps Lock" => KeyCode::KCapsLock,
        "Esc" => KeyCode::KEsc,
        "Space" => KeyCode::KSpace,
        "Page Up" => KeyCode::KPageUp,
        "Page Down" => KeyCode::KPageDown,
        "End" => KeyCode::KEnd,
        "Home" => KeyCode::KHome,
        "Arrow Left" => KeyCode::KArrowLeft,
        "Arrow Up" => KeyCode::KArrowUp,
        "Arrow Right" => KeyCode::KArrowRight,
        "Arrow Down" => KeyCode::KArrowDown,
        "Print Screen" => KeyCode::KPrintScreen,
        "Insert" => KeyCode::KInsert,
        "Delete" => KeyCode::KDelete,
        _ => KeyCode::None,
    }
}
/// Returns the keycode from the key name.
///
/// # Examples
///
/// ```
/// assert_eq!(string_to_key("T"), KeyCode::KT);
/// assert_eq!(string_to_key("some invalid text"), KeyCode::None);
/// ```
Returns the keycode from the key name.
Returns the keycode from the key name .
pub fn string_to_key(key_name: &str) -> KeyCode {
    match key_name {
        "0" => KeyCode::K0,
        "1" => KeyCode::K1,
        "2" => KeyCode::K2,
        "3" => KeyCode::K3,
        "4" => KeyCode::K4,
        "5" => KeyCode::K5,
        "6" => KeyCode::K6,
        "7" => KeyCode::K7,
        "8" => KeyCode::K8,
        "9" => KeyCode::K9,
        "A" => KeyCode::KA,
        "B" => KeyCode::KB,
        "C" => KeyCode::KC,
        "D" => KeyCode::KD,
        "E" => KeyCode::KE,
        "F" => KeyCode::KF,
        "G" => KeyCode::KG,
        "H" => KeyCode::KH,
        "I" => KeyCode::KI,
        "J" => KeyCode::KJ,
        "K" => KeyCode::KK,
        "L" => KeyCode::KL,
        "M" => KeyCode::KM,
        "N" => KeyCode::KN,
        "O" => KeyCode::KO,
        "P" => KeyCode::KP,
        "Q" => KeyCode::KQ,
        "R" => KeyCode::KR,
        "S" => KeyCode::KS,
        "T" => KeyCode::KT,
        "U" => KeyCode::KU,
        "V" => KeyCode::KV,
        "W" => KeyCode::KW,
        "X" => KeyCode::KX,
        "Y" => KeyCode::KY,
        "Z" => KeyCode::KZ,
        "F1" => KeyCode::KF1,
        "F2" => KeyCode::KF2,
        "F3" => KeyCode::KF3,
        "F4" => KeyCode::KF4,
        "F5" => KeyCode::KF5,
        "F6" => KeyCode::KF6,
        "F7" => KeyCode::KF7,
        "F8" => KeyCode::KF8,
        "F9" => KeyCode::KF9,
        "F10" => KeyCode::KF10,
        "F11" => KeyCode::KF11,
        "F12" => KeyCode::KF12,
        "Back Space" => KeyCode::KBackspace,
        "Tab" => KeyCode::KTab,
        "Enter" => KeyCode::KEnter,
        "Shift" => KeyCode::KShift,
        "Ctrl" => KeyCode::KCtrl,
        "Alt" => KeyCode::KAlt,
        "Caps Lock" => KeyCode::KCapsLock,
        "Esc" => KeyCode::KEsc,
        "Space" => KeyCode::KSpace,
        "Page Up" => KeyCode::KPageUp,
        "Page Down" => KeyCode::KPageDown,
        "End" => KeyCode::KEnd,
        "Home" => KeyCode::KHome,
        "Arrow Left" => KeyCode::KArrowLeft,
        "Arrow Up" => KeyCode::KArrowUp,
        "Arrow Right" => KeyCode::KArrowRight,
        "Arrow Down" => KeyCode::KArrowDown,
        "Print Screen" => KeyCode::KPrintScreen,
        "Insert" => KeyCode::KInsert,
        "Delete" => KeyCode::KDelete,
        _ => KeyCode::None,
    }
}
pub fn string_to_key ( key_name : & str ) -> KeyCode { match key_name { " " => KeyCode :: K0 , " " => KeyCode :: K1 , " " => KeyCode :: K2 , " " => KeyCode :: K3 , " " => KeyCode :: K4 , " " => KeyCode :: K5 , " " => KeyCode :: K6 , " " => KeyCode :: K7 , " " => KeyCode :: K8 , " " => KeyCode :: K9 , " " => KeyCode :: KA , " " => KeyCode :: KB , " " => KeyCode :: KC , " " => KeyCode :: KD , " " => KeyCode :: KE , " " => KeyCode :: KF , " " => KeyCode :: KG , " " => KeyCode :: KH , " " => KeyCode :: KI , " " => KeyCode :: KJ , " " => KeyCode :: KK , " " => KeyCode :: KL , " " => KeyCode :: KM , " " => KeyCode :: KN , " " => KeyCode :: KO , " " => KeyCode :: KP , " " => KeyCode :: KQ , " " => KeyCode :: KR , " " => KeyCode :: KS , " " => KeyCode :: KT , " " => KeyCode :: KU , " " => KeyCode :: KV , " " => KeyCode :: KW , " " => KeyCode :: KX , " " => KeyCode :: KY , " " => KeyCode :: KZ , " " => KeyCode :: KF1 , " " => KeyCode :: KF2 , " " => KeyCode :: KF3 , " " => KeyCode :: KF4 , " " => KeyCode :: KF5 , " " => KeyCode :: KF6 , " " => KeyCode :: KF7 , " " => KeyCode :: KF8 , " " => KeyCode :: KF9 , " " => KeyCode :: KF10 , " " => KeyCode :: KF11 , " " => KeyCode :: KF12 , " " => KeyCode :: KBackspace , " " => KeyCode :: KTab , " " => KeyCode :: KEnter , " " => KeyCode :: KShift , " " => KeyCode :: KCtrl , " " => KeyCode :: KAlt , " " => KeyCode :: KCapsLock , " " => KeyCode :: KEsc , " " => KeyCode :: KSpace , " " => KeyCode :: KPageUp , " " => KeyCode :: KPageDown , " " => KeyCode :: KEnd , " " => KeyCode :: KHome , " " => KeyCode :: KArrowLeft , " " => KeyCode :: KArrowUp , " " => KeyCode :: KArrowRight , " " => KeyCode :: KArrowDown , " " => KeyCode :: KPrintScreen , " " => KeyCode :: KInsert , " " => KeyCode :: KDelete , _ => KeyCode :: None , } }
Returns the keycode from the key name.
Returns the keycode from the key name .
key_name
&str
examples
```
assert_eq!(string_to_key("T"), KeyCode::KT);
assert_eq!(string_to_key("some invalid text"), KeyCode::None);
```
` ` ` assert_eq! ( string_to_key ( " T " ) KeyCode :: KT ) ; assert_eq! ( string_to_key ( " some invalid text " ) KeyCode :: None ) ; ` ` `