6

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

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
prvit
  • 956
  • 3
  • 9
  • 22

2 Answers2

7

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

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • actually I want to add a log and only than terminate the app. thank you, will try ur advice – prvit Feb 18 '13 at 15:04
3

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.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364