C#中的Keydown事件问题 [英] Keydown event problem in C#
问题描述
我的问题是我使用按键事件,但在按键e.KeyCode == Keys.E&& e.Control正常工作但e.KeyCode == Keys.N&& e.Control不工作为什么它只能用Cntrl + shift + N plz帮助我
我尝试了什么:
e.KeyCode == Keys.N&& e.Control
My problem is that I use key down event but in key down "e.KeyCode == Keys.E && e.Control" is working proper but "e.KeyCode == Keys.N && e.Control" is not working Why its working only with Cntrl+shift+N plz help me
What I have tried:
"e.KeyCode == Keys.N && e.Control"
推荐答案
它的工作原理对我来说很好:
It works fine for me:
private void frmTest_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.N && e.Control)
{
Console.WriteLine("CTRL+N");
}
}
猜测,你没有将KeyPreview设置为true,或者你有一个快捷键分配给CTRL + E或CTRL + N,它们优先获得。
如果这没有帮助,我们将需要更多关于您如何使用该代码的信息。
At a guess, you don't have KeyPreview set to true, or you have a shortcut key assigned to CTRL+E or CTRL+N which is getting precedence.
If that doesn't help, we will need a load more info on exactly how you are using that code.
这篇关于C#中的Keydown事件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!