Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Ctrl + C" buttons pressed handle C# console app

How can I handle two buttons pressed simultaneously ('Ctrl' + 'C'), not in the WindowsForms application, but in console C# application?

like image 354
prvit Avatar asked Feb 18 '13 15:02

prvit


2 Answers

I suspect you want to set Console.TreatCtrlCAsInput to true. (Assuming you don't want this to terminate the app.)

like image 57
Jon Skeet Avatar answered Sep 22 '22 21:09

Jon Skeet


Check out Console.TreatControlCAsInput property;

Gets or sets a value indicating whether the combination of the Control modifier key and C console key (Ctrl+C) is treated as ordinary input or as an interruption that is handled by the operating system.

like image 44
Soner Gönül Avatar answered Sep 22 '22 21:09

Soner Gönül