/// <summary> /// Creates new intanse of <see cref="KeyboardListener" />. New Text event will be fired on EndSymbol. /// </summary> /// <param name="startSymbol"></param> /// <param name="endSymbol"></param> public KeyboardListener(char startSymbol, char endSymbol) { StartSymbol = startSymbol; EndSymbol = endSymbol; Strategy = ReadStrategy.DependsOnSymbols; _hook = new GlobalKeyboardHook(); _hook.KeyboardPressed += KeyPressed; }
/// <summary> /// Creates new intanse of <see cref="KeyboardListener" />. New Text event will be fired on string with passed length. /// </summary> /// <param name="stringLength"></param> public KeyboardListener(int stringLength) { if (stringLength < 1) { throw new ArgumentOutOfRangeException($"{nameof(stringLength)} must be greater than 0"); } StringLength = stringLength; Strategy = ReadStrategy.DependsOnLength; _hook = new GlobalKeyboardHook(); _hook.KeyboardPressed += KeyPressed; }
/// <summary> /// Creates new intanse of <see cref="KeyboardListener" />. New Text event will be fired on Enter. /// </summary> public KeyboardListener(bool fireNewTextOnEnter = false) { if (fireNewTextOnEnter) { Strategy = ReadStrategy.DependsOnEnter; } else { Strategy = ReadStrategy.Disabled; } _hook = new GlobalKeyboardHook(); _hook.KeyboardPressed += KeyPressed; }