Added keyboard input optimized for the game loop.