...
public yourClass : Monobehavior
{
public float firstWpress=0;
public int count=0;
void Update()
{
// Check for the W key.
if (Input.GetKeyDown(KeyCode.W))
{
// The current time
var currentTime=Time.time;
// Is this the first time W was pressed?
if (count==0)
{
firstWpress=Time.time; // Save the time of first
}
count++; // increase the key count.
if (count==4) // has the key been pressed 4 times?
{
count=0; // Reset the counter
if (currentTime-firstWpress<1) // was it under 1 second?
{
// It was pressed 4 times within a second
// Do your logic here.
}
}
if (currentTime-firstWpress>1) // Reset the counter if it's been longer that 1 second.
{
count=0;
}
}
}
}
I haven’t tried the code, but I hope that would give you some idea.