Not quite sure what "is equal to" actually means...
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
:laugh:
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
The answer's in the code. UP in SPACE is where the coder seems to be. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
[Message Deleted]
-
[Message Deleted]
No, this was originaly posted in the C# forum by Mc_Topaz and I copied it here as an example of "why the hell did you do that and then ask why it doesn't work?". Hence the "From our own C# forum" and "What do they teach them" bits.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
[Message Deleted]
Andrew Pallant wrote:
I am not one to usually say anything about posting in the wrong forum, but you really did this time.
Did you actually read the post? The OP didn't post a programming question at all, he's pointing out a very misguided bit of code posted by someone else.
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
I wonder if one can actually press the keys fast enough, without keeping the other one pressed :laugh: Nice one. Cheers
You have the thought that modern physics just relay on assumptions, that somehow depends on a smile of a cat, which isn’t there.( Albert Einstein)
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
LOL - suggest him to save the last pressed key. If the currently pressed key is space und the last key was keyup or vice versa then his condition is fulfilled.
-
From our own C# forum again:
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?
Um - what do they teach them? And why?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
First, this person seems to be in school and is currently learning programming. Next, this posting IS appropriate for the C# forum. This person's folly is obviously their lack of paying attention to the precise nature of all pieces of the code (ie. KeyCode cannot equal to different things). They are thinking of the "if" statement as a perverse non-procedural construct, similar to an SQL "select" statement. However, the imagination displayed here is in the spirit of a real programming concept: bit mask.
-
First, this person seems to be in school and is currently learning programming. Next, this posting IS appropriate for the C# forum. This person's folly is obviously their lack of paying attention to the precise nature of all pieces of the code (ie. KeyCode cannot equal to different things). They are thinking of the "if" statement as a perverse non-procedural construct, similar to an SQL "select" statement. However, the imagination displayed here is in the spirit of a real programming concept: bit mask.
No, his folly was to post the question here. I don't know if he has ADS or something, but the red warning of not posting programming questions here is hard to overlook. I always marvel anew at those that don't even spend 0.2 seconds to verify if the place they ask a programming question is even remotely right. Maybe we should redirect them to some forum about cats next time, it's certainly not a wronger place to ask.
-
No, his folly was to post the question here. I don't know if he has ADS or something, but the red warning of not posting programming questions here is hard to overlook. I always marvel anew at those that don't even spend 0.2 seconds to verify if the place they ask a programming question is even remotely right. Maybe we should redirect them to some forum about cats next time, it's certainly not a wronger place to ask.