10

I am using C# windows Application

I am checking which key, user have pressed down by keyboard. I have checked for all keys but its not working in case of printScreen

private void comboBox1_KeyDown(object sender, KeyEventArgs e)
{
        MessageBox.Show(e.KeyCode.ToString());
}

So how to detect PrintScreen Key

Sastrija
  • 3,284
  • 6
  • 47
  • 64
Javed Akram
  • 15,024
  • 26
  • 81
  • 118
  • 2
    Is it mandatory to detect printscreen with keydown? it is captured by keyup! –  Nov 27 '10 at 17:50
  • @HPT: You're right, you should post this as an answer. – casablanca Nov 27 '10 at 18:03
  • The thing is I have the same issue, and I am using the KeyUp event. When I make a new Silverlight app, I can catch the print screen key. But in my old Silverlight app that has some Telerik components in it, this is not working any clue why this is so? – Rumplin Mar 06 '11 at 08:21

4 Answers4

12

You can use KeyUp, It captures PrintScreen key.

Sastrija
  • 3,284
  • 6
  • 47
  • 64
7

The print-screen key is trapped by the OS before it is sent to applications. To detect such keys, you need to use a keyboard hook. You may be interested in this article: Low-level Windows API hooks from C# to stop unwanted keystrokes

casablanca
  • 69,683
  • 7
  • 133
  • 150
3

You can use

e.Key == Key.Snapshot

This will work on KeyUp event

Mayur Dhingra
  • 1,527
  • 10
  • 27
0

If the KeyUp event still does not work try modifying the forms KeyPreview property to true, then test the the KeyUp event again.

DIF
  • 2,470
  • 6
  • 35
  • 49
Saechel
  • 152
  • 10