Capturing Control + Shift + Enter

V

Vazz

I am trying to capture the key combination "Control + Shift + Enter"
in a KeyDown event. I am able capture "Control + Enter" using
(e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
check if there are two Modifiers?
 
V

Vadim Chekan

Vazz said:
I am trying to capture the key combination "Control + Shift + Enter"
in a KeyDown event. I am able capture "Control + Enter" using
(e.KeyCode == Keys.Enter && e.Modifiers == Keys.Control). How do I
check if there are two Modifiers?

if (e.KeyCode == Keys.Enter && e.Control && e.Shift) {

}

Vadim Chekan.
 
T

Tyler Dixon

Vadim said:
if (e.KeyCode == Keys.Enter && e.Control && e.Shift) {

}

Vadim Chekan.

Doesn't that need to be a bitwise AND?

if (e.KeyCode == (Keys.Enter & e.Control & e.Shift) )
{
}
 
V

Vazz

Thanks guys. Its actually ((e.KeyCode == Keys.Enter) && e.Shift &&
e.Control). Works now.

Vazz
 
V

Vadim Chekan

Tyler said:
Doesn't that need to be a bitwise AND?

if (e.KeyCode == (Keys.Enter & e.Control & e.Shift) )

No!
"Bitwize AND" of two bool variables (e.Control & e.Shift) it not wise!

Vadim Chekan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top