Multiple key presses doing different events in C#
Posted
by Nevik Eeirnb
on Stack Overflow
See other posts from Stack Overflow
or by Nevik Eeirnb
Published on 2010-04-21T19:37:20Z
Indexed on
2010/04/21
19:53 UTC
Read the original article
Hit count: 114
Hi,
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.W)
player1.moveUp();
if (e.KeyCode == Keys.NumPad8)
player2.moveUp();
}
In the above code the moveUp methods basically just increment a value. I want it so both keys can be pressed (or held down)at the same time and both events will trigger. Thanks, Nevik
© Stack Overflow or respective owner