static Keys tecla;
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
tecla = e.KeyCode;
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
tecla = Keys.Escape;
}
private void timer1_Tick(object sender, EventArgs e)
{
switch (tecla)
{
case Keys .Left:
this.pictureBox1.Location = new Point
(pictureBox1
.Location.X - 1, pictureBox1
.Location.Y); break;
case Keys.Right :
this.pictureBox1.Location = new Point
(pictureBox1
.Location.X + 1, pictureBox1
.Location.Y); break;
case Keys.Up :
this.pictureBox1.Location = new Point
(pictureBox1
.Location.X, pictureBox1
.Location.Y-1); break;
case Keys.Down :
this.pictureBox1.Location = new Point
(pictureBox1
.Location.X , pictureBox1
.Location.Y+1); break;
}
}