// Public so that the NextPieceForm can forward key presses. // Otherwise, there would be confusion if the NextPieceForm has focus. public void AcceptInput(Keys keyData) { // Without this call the tick event will never be processed if a key is held down Application.DoEvents(); if (game.IsGameRunning) { bool refresh = false; switch (keyData) { case Keys.Down: game.MoveDown(); refresh = true; break; case Keys.Left: game.MoveLeft(); refresh = true; break; case Keys.Right: game.MoveRight(); refresh = true; break; case Keys.Up: game.Rotate(); refresh = true; break; } if (refresh) { gridBoard.Invalidate(); gridBoard.Update(); nextPieceForm.ForceUpdate(); } } }