简体   繁体   English

我想在WinForm中捕获ctrl + space键事件

[英]I coudlnt catch ctrl+space key event in WinForm

I couldnt catch ctrl+space key event in winForm.But i wrote this code ((e.KeyCode==Keys.Space)&&(e.Modifiers==Keys.Control)) it didnt work.What is the problem? 我无法在winForm中捕获ctrl + space键事件。但我写了这段代码((e.KeyCode==Keys.Space)&&(e.Modifiers==Keys.Control))它没有用。问题是什么?

[EDIT]sorry.problem is in another thing.It works. [编辑] sorry.problem是另一回事。它的工作原理。

尝试(e.Modifiers & Keys.Control == Keys.Control)而不是(e.Modifiers==Keys.Control)

Here is my suggestion: 这是我的建议:

if (e.KeyData.HasFlag(Keys.Space) && e.KeyData.HasFlag(Keys.Control))
{
    // DoSomething
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM