0

Possible Duplicate:
KeyDown : recognizing multiple keys

Hi, I would need to differ between two actions: key A is pressed and key A is pressed while CTRL is being pressed. I am doing that:

..keyEventArgs k

if(k.Control)
{
  if(k.code==Keys.A)
   ..
}
else
{
  if(k.code==Keys.A)
    ..

}

Is that correct?

Community
  • 1
  • 1
FlyBoy
  • 1,115
  • 1
  • 9
  • 10

3 Answers3

0

Well, does it work?

Anyway, here are some examples you can use:

http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx

Ilya Kogan
  • 21,995
  • 15
  • 85
  • 141
0

take a look to this post my friend ;)

How to use multiple modifier keys in C#

:)

Community
  • 1
  • 1
JAiro
  • 5,914
  • 2
  • 22
  • 21
0

Juding from the Control property, you are using winforms.

Yes, but consider writing it as follows:

if(k.KeyCode==Keys.A)
{
    if(k.Control)
    {
        ... Control+a
    }
    else
    {
        ... a
    }
}
Steven Jeuris
  • 18,274
  • 9
  • 70
  • 161