public static byte[] GetKeySequence(string key, bool applicationMode) { if (KeyTranslations.TryGetValue(key, out KeyboardTranslation translation)) { return(applicationMode ? translation.ApplicationMode : translation.NormalMode); } return(null); }
/// <summary> /// Translates a key sequence from text to DEC VT byte codes /// </summary> /// <param name="key">The key formatted as text as seen in the dictionary below.</param> /// <param name="applicationMode">Set to true if the application mode mapping is desired</param> /// <returns></returns> public static byte[] GetKeySequence(string key, bool control, bool shift, bool applicationMode) { if (KeyTranslations.TryGetValue(key, out KeyboardTranslation translation)) { if (applicationMode && translation.ShiftOnApplication && !string.IsNullOrEmpty(translation.Shift)) { return(translation.Shift.To8()); } if (shift) { return(string.IsNullOrEmpty(translation.Shift) ? null : translation.Shift.To8()); } if (control) { return(string.IsNullOrEmpty(translation.Control) ? null : translation.Control.To8()); } return(string.IsNullOrEmpty(translation.Normal) ? null : translation.Normal.To8()); } return(null); }