static void Main() { InterceptKeys.SetupHook(KeyDown); while (true) { ConsoleKey key = Console.ReadKey(true).Key; Console.WriteLine("ReadKey: " + key); if (key == ConsoleKey.Escape) { break; } } InterceptKeys.ReleaseHook(); }
/// <summary> /// Hook key event on KeyDown press. /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void KeyHook(object o, DoWorkEventArgs e) { InterceptKeys.SetupHook(KeyDown); InterceptKeys.ReleaseHook(); }