KeyDown event not Working on PrintScreen Key

人走茶凉 提交于 2019-12-01 15:18:09

问题


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


回答1:


You can use KeyUp, It captures PrintScreen key.




回答2:


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




回答3:


You can use

e.Key == Key.Snapshot

This will work on KeyUp event




回答4:


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



来源:https://stackoverflow.com/questions/4292925/keydown-event-not-working-on-printscreen-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!