I coudlnt catch ctrl+space key event in WinForm

1.3k views Asked by At

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?

[EDIT]sorry.problem is in another thing.It works.

2

There are 2 answers

0
George Mamaladze On BEST ANSWER

Try (e.Modifiers & Keys.Control == Keys.Control) instead of (e.Modifiers==Keys.Control)

0
Fischermaen On

Here is my suggestion:

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