I dont know why you've tagged your question with C#, because your code clearly isnt ... anyway
have you looked at
SetConsoleCtrlHandler function (Windows)[
^] ?
I have a console process in c# that uses Control-C to 'trip' an event and do more work or in another case to raise a signal to a BackgroundWorker that it should stop what its doing .. in both cases, and this is where it gets into a grey area, I then continue to do work, even allowing Control-C to be used again (as opposed to a comment I saw, suggesting that the handler had to do its work quickly else the program would become unstable .. I guess the handler does do its work quickly - raises an event, but, the Control-C/Control-Break etc is trapped) and I can do whatever afterwards
Im pretty sure there's VB.Net code showing how to use SetConsoleCtrlHandler - this maybe
AddressOf.com : Console Event Handling[
^]
[edit] sorry, this only answers part of your question, I'd have to think about the keyboard part... at a pinch I'd be thinking of setting a flag to say 'Im working', then when the flag is 'unset', ie work has finished, flushing the keyboard buffer [/edit]