Hi,
To handle arrow keys, ESC, TAB, RETURN you must override IsInputKey method. More informations you can find here:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown%28v=vs.110%29.aspx[
^]
Instead of using KeyDown event you can override Form's ProcessCmdKey method. This should do the trick:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Down)
{
Direction = "D";
return true;
}
else if (keyData == Keys.Left)
{
Direction = "L";
return true;
}
else if (keyData == Keys.Right)
{
Direction = "R";
return true;
}
else if (keyData == Keys.Up)
{
Direction = "U";
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Cheers!