开发者

KeyDown event not Working on PrintScreen Key

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 comb开发者_如何学JAVAoBox1_KeyDown(object sender, KeyEventArgs e)
{
        MessageBox.Show(e.KeyCode.ToString());
}

So how to detect PrintScreen Key


You can use KeyUp, It captures PrintScreen key.


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


You can use

e.Key == Key.Snapshot

This will work on KeyUp event


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜