By default, the arrow keys are not handled by a control's key processing code, but instead are filtered out for focus management. Hence, the control's KeyDown, KeyUp and KeyPressed events are not raised when you press an arrow key. If you want a control to handle these keyboard events, then override the control's IsInputKey method.
using System.Windows.Forms;
protected override bool IsInputKey( Keys keyData )
{
switch ( keyData )
{
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
return true;
}
return base.IsInputKey( keyData );
}
You can then process the keys by overriding the control's OnKeyDown method.
Contributed from George Shepherd's Windows Forms FAQ