• 0

[C#] Alt Key and Control Key


Question

Sup guys...

I posted before a question regarding ProcessCmdKey (How to catch Shift+Alt+Key, i changed that for Shift+Alt+Up btw) that works fine, I do it this way:

if ((Keys.Up | Keys.Shift | Keys.Alt) == keyData)
               /* Does whatever*/

So far so good, let's say I want to do it with Control+Alt+Up, I'd say it should go:

if ((Keys.Up | Keys.Control | Keys.Alt) == keyData)
               /* Does whatever*/

Now, when I put Alt+Control together it doesn't seem to work, it won't go into the If :wacko: , seems to go into a conflict when I try Alt+Control together :pinch:

Anyone knows about this? Thanks :p

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

have you tried using Keys.ControlKey instead of Keys.Control ? The MSDN documentation calls Keys.Control "the CTRL modifier key" and Keys.ControlKey "the CTRL key" - does that make a difference in using these things?

(i notice its the same with the Alt key, except its Keys.Alt and Keys.Menu for those two...)

this is just a stab in the dark, however, trying to give you some direction.

Link to comment
Share on other sites

  • 0

Uhmm you know what?

It's the Up arrow the one it's getting in the way, if i do:

if ((Keys.E | Keys.Control | Keys.Alt | Keys.Shift) == keyData)

It works, but, if i do

if ((Keys.Up | Keys.Control | Keys.Alt | Keys.Shift) == keyData)

It doesn't :pinch:

I'm using a control named Tlist BTW, any one heard about it ?

Link to comment
Share on other sites

  • 0

Does this work:

private void Key_Down(object sender, System.Windows.Forms.KeyEventArgs  e)
  {
  	if(e.KeyCode == Keys.Alt)
{
if(e.KeyCode == Keys.Shift)
{
if(e.KeyCode == Keys.Up)
{

}
}
}
}

Link to comment
Share on other sites

  • 0

It works if i'm using KeyDown, but i'm, using ProcessCmdKey, which goes first than KeyDown, and ProcessCmdKey doesn't get any KeyEventArgs as argument :wacko:

Link to comment
Share on other sites

  • 0

Oh - sorry :blush: Didn't read well. However, it works perfectly fine for me :) I don't understand what's the problem. I've tried every key combination and nothing worked except control+alt+up at once.

Link to comment
Share on other sites

  • 0

I suspect the problem is that you are using a listControl, which normally would intercept the up key. The way ProcessCmdKey works is it passes the message down the chain of controls until someone uses it. So I THINK the control is intercepting the up key before you can. :)

Dan

Link to comment
Share on other sites

  • 0
I suspect the problem is that you are using a listControl, which normally would intercept the up key.  The way ProcessCmdKey works is it passes the message down the chain of controls until someone uses it.  So I THINK the control is intercepting the up key before you can.  :)

Dan

585199358[/snapback]

Yes - that makes sense :yes:

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.