我正在使用C#windows Application
我正在检查用户用键盘按下了哪个键。 我检查了所有密钥,但是在printScreen
的情况下它不起作用private void comboBox1_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString());
}
那么如何检测 PrintScreen Key
答案 0 :(得分:10)
您可以使用KeyUp,它会捕获 PrintScreen 键。
答案 1 :(得分:6)
在将打印屏幕密钥发送到应用程序之前,它会被操作系统捕获。要检测此类密钥,您需要使用keyboard hook。您可能对本文感兴趣:Low-level Windows API hooks from C# to stop unwanted keystrokes
答案 2 :(得分:3)
您可以使用
e.Key == Key.Snapshot
这将适用于KeyUp事件
答案 3 :(得分:0)
如果KeyUp
事件仍无效,请尝试将表单KeyPreview
属性修改为true
,然后再次测试KeyUp事件。