Time between two actions

I’m using Time.time in my code right now, but the timer keeps going and never resets for some reason… I’m stumped. Is this even the right way to time something? Say you press a key and want to take the total time until the next key press, that’s basically what I’m trying to do.

[Example: You press the ‘D’ key, and then 2.3 seconds later press the ‘E’ key. Does time.time work for this??]

public float timeRate = 0.5f;
public float orderTime = 0.0f;

void update()
{
if (generated)
{ 
			orderTime = 0.0f;
			orderTime = orderTime + (Time.time - timeRate);
}

if (!generated)
		{

			orderTime = 0.0f;
}
Debug.Log (orderTime);
}

using UnityEngine;
using System.Collections;

public class TimeToNextKey : MonoBehaviour {
	float timer;
	bool onKeyDown = false;

	void Update () {
		//if on Key pressed then
	if (Input.anyKeyDown) {
			//if its the first input
		if(onKeyDown == false)
			{
				//set our timer to now Time
				timer = Time.time;
				//on key is pressed
				onKeyDown = true;
			}
			//if its the second input
			else
			{
				//log the time past the set of the timer
				Debug.Log(Time.time-timer);
				//reset all
				onKeyDown = false;
			}
		}
	}
}

Ty it.