I'm making a game in C# in Forms in Visual Studio and I'm currently registering key presses from the player with the keyDown event and it works well. When the player is holding down a button it gets pressed once, there is a delay and then the key is registered many times over and over, which is good, but if any other key that I'm checking for gets pressed while the first key is being held, the new key is registered once and then nothing more, just like when typing. I want it so that if key is pressed while another is being held, the first key is registered once, and then the first key, that's being held, keeps outputting.
I'm currently getting:
aaaaaaaaaaaaaaaaaap
but I want:
aaaaaaaaaaaaaaaaaapaaaaaaaaaaaaaa
if that makes sense
Is it possible?
Here is my current method:
private void GUItetris_KeyDown(object sender, KeyEventArgs e)
{
if (!Tetris.gameOver && Tetris.gameBoard != null)
{
if (e.KeyCode == Keys.A) // a
{
Tetris.gameBoard.activePiece.MoveLeft(Tetris.gameBoard.boardColor);
Tetris.gameBoard.UpdatePiece();
}
if (e.KeyCode == Keys.D) //d
{
Tetris.gameBoard.activePiece.MoveRight(Tetris.gameBoard.boardColor);
Tetris.gameBoard.UpdatePiece();
}
if (e.KeyCode == Keys.S) //s
{
Tetris.gameBoard.activePiece.MoveDown(Tetris.gameBoard.boardColor);
Tetris.gameBoard.UpdatePiece();
}
if (e.KeyCode == Keys.P) // p
{
Tetris.gameBoard.activePiece.Rotate(Tetris.gameBoard.boardColor, true);
Tetris.gameBoard.UpdatePiece();
}
if (e.KeyCode == Keys.L) // l
{
Tetris.gameBoard.activePiece.Rotate(Tetris.gameBoard.boardColor, false);
Tetris.gameBoard.UpdatePiece();
}
}
}