I'm trying to detect the Print Screen key on my form, but keys like Prtsc and SysRq don't fire the KeyDown
event..
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
// Trying to detect if it fires KeyDown, but it doesn't
MessageBox.Show(e.KeyValue.ToString());
}
I can't figure it out, maybe I'm really dumb..
It can be done, but it's not straightforward. You can't do it with the KeyPress
or KeyDown
events: as you have discovered, it doesn't make them fire.
But you can still do it with c#: you just have to use the Windows APIs. Because the relevant code is lengthy, I'm posting the link:
Capturing the Print Screen Key
Incidentally, you're not dumb. :) Even though this seems like it should have an obvious, simple answer, it doesn't: this is genuinely complex to make happen. But it can be done.