few buttondown in fixed time

Hi.
Can anybody help with the next problem. Need method whick returns true if some button was pressed in needed time.
Example what i mean:

private bool PressedTwice(KeyCode button, float DelayBetweenButtonDowns)
{
if(///Button was clicked twice in this time period///)
{return true;}
else{return false;}

}

Also how can i get
if button was clicked in last 1sec for example?

using UnityEngine;
using System.Collections.Generic;

public class DoubleKeyPressTest : MonoBehaviour {

	Dictionary<KeyCode, float> KeyPressTimes = new Dictionary<KeyCode, float>();
		
	// Update is called once per frame
	void Update () 
	{
		KeyCode testKey = KeyCode.A;
		float testTime = 1f;
	
		if (PressedTwice (testKey, testTime))
		{
			Debug.Log("pressed twice returned true");
		}
	}

	private bool PressedTwice(KeyCode key, float timeRangeForDoublePress) 
	{ 
		bool result = false;

		if (Input.GetKeyDown(key))
		{
			if (KeyPressTimes.ContainsKey(key))
			{
				if (Time.time - KeyPressTimes[key] < timeRangeForDoublePress)
				{
					result = true;
				}
				Debug.Log("Time between key presses " + key + " is " + (Time.time - KeyPressTimes[key]) + " seconds");
				KeyPressTimes[key] = Time.time;
			}
			else
			{
				KeyPressTimes.Add(key, Time.time);
			}
		}

		return result;
	}
}