المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : KeyEventArgs question: Get one of the arrow keys and space key at the same time



C# Programming
06-25-2009, 03:50 PM
Hi!

In a simple game I'm creating, I need to trigger some methods when one of the arrow keys are pressed as well as the space key.

I'm using this code in the form to receive the keyboard inputs:

protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);

if (e.KeyCode == Keys.Up && e.KeyCode == Keys.Space)
MessageBox.Show("UP & SPACE");
}

Nothing happens when I run the code. The OnKeyDown event don't seem to handle this condition at all.

How shall I solve this problem?