-
Notifications
You must be signed in to change notification settings - Fork 0
10. KeyActionPair
ConsoleKeyInfo has a default constructor ConsoleKeyInfo(char keyChar, ConsoleKey key, bool shift, bool alt, bool ctrl). While combination of modifiers are not common to use, here is an additional constructor with setting modifiers default false.
ConsoleKeyInfo(char keyChar, ConsoleKey key);
Returns ConsoleKeyInfo
- char keyChar: A char to create ConsoleKeyInfo. See ConsoleKeyInfo on Microsoft.
- ConsoleKey key: Value of ConsoleKey enum. See See ConsoleKey on Microsoft.
This is public list of Tuple values of ConsoleKeyInfo and Action. List is public to use List's additional features which is not available on HelpConsole yet.
KeyActionPairList is a list of Tuple<ConsoleKeyInfo, Action>
AddKeyActionPair(ConsoleKeyInfo cki, Action action);
- ConsoleKeyInfo cki: ConsoleKeyInfo which is created by default or additional constructor that will be used to pair Key-Action.
- Action action: Action that will be called when given
ckiis paired with a value inKeyActionPairList.
Listing of Tuple values of KeyActionPairList.
ListKeyActionPairList();
Clears list of KeyActionPairList.
ClearKeyActionPairList();
WaitKeyAction();
Wait for a key to be pressed and read it via Console.ReadKey() then call KeyAction(ConsoleKeyInfo cki) to call given Action which is defined on KeyActionPairList.
KeyAction(ConsoleKeyInfo cki);
Call given action if it has a key with given cki on KeyActionPairList, if not writes on debug output.