How to make a triple key input
So I'm creating a text based game, where there are game states including the story and choices and what not, so I have a simple code that allows the user to use key inputs from W, A, and D in order to move between game states. I want to incorporate a point where the player must hit the S key 3 times in a row in order to proceed to a specific game state(from a specific game state). The code I have right now allows this by making that Input specified to a point in the array called 'nextStates' which I can put the triple input in and then just make that have a game state if I need one there. The problem is that I have no idea how to make the game recognize that the S key was pressed 3 times. I looked around and I haven't found anything that I can understand, as I'm brand new to this, so here's my code for right now. Any help would be appreciated :)
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class AdventureGame : MonoBehaviour {
[SerializeField] Text textComponent;
[SerializeField] State startingState;
State state;
// Start is called before the first frame update
void Start()
{
state = startingState;
textComponent.text = state.GetStateStory();
}
// Update is called once per frame
void Update()
{
ManageState();
}
private void ManageState()
{
var nextStates = state.GetNextStates();
if (Input.GetKeyDown(KeyCode.W))
{
state = nextStates[0];
}
else if (Input.GetKeyDown(KeyCode.D))
{
state = nextStates[1];
}
else if (Input.GetKeyDown(KeyCode.A))
{
state = nextStates[2];
}
textComponent.text = state.GetStateStory();
}
}