I'm working on making pong in C#, and I've come across a problem. I have KeyPreview on, and here's my code
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Up || e.KeyChar == (char)Keys.W) {
picPaddle.Top -= 10;
}
else if (e.KeyChar == (char)Keys.Down || e.KeyChar == (char)Keys.S) {
picPaddle.Top += 10;
}
}
When I press any of the keys, nothing happens. The only time a keypress works is if it tests the condition for (char)Keys.Enter. Why is this? How can I make the form take KeyPress for keys other than enter?