How to make a delay on key input?

I have pretty much started c# and unity a few weeks ago and so far I could make a lot of stuff, but currently I´m stuck with the problem:

I wanted to spawn a cube when I press X.
However, I can spam X and therefore create that many cubes that unity starts lagging.
I wanted to build some kind of delay that prevents the button spamming.

using UnityEngine;
using System.Collections;

public class SpawnTest : MonoBehaviour 
{
	public Vector3 ObjectSpawnPosition;
	public GameObject obj;
	public float SpawnRate = 1F;
	private float DelayTimer = 0F;


	void Update () 
	{

		if (Input.GetKeyDown(KeyCode.X) && Time.time > DelayTimer)
		{

			Instantiate (obj, ObjectSpawnPosition, Quaternion.identity);
			DelayTimer -= Time.time + SpawnRate;
		}


	}
}

I did read a lot of stuff about Invoke, Couroutine, WaitForSeconds, IEnumerator… but everything seems not to solve this issue, or I´m just to dumb to understand -.-

sorry for my bad english, I hope someone can help to solve this or better to understand this problem.

A additional problem is that I create to many “clones” of the object. Is there any way to prevent this from happening?

try something like

private bool spawned = false;
private float decay;

void Update ()
{
Reset();
if (Input.GetKeyDown(KeyCode.X) && !spawned)
{
    decay = 1f;
    spawned = true;
    Instantiate (obj, ObjectSpawnPosition, Quaternion.identity);
}  
}

private void Reset()
{
	if(spawned && decay > 0)
	{
		decay -= Time.delta;
	}
	if(decay < 0)
	{
		decay = 0;
		spawned = false;
	}
}

Try this mod to your code:

using UnityEngine;
using System.Collections;
 
public class SpawnTest : MonoBehaviour 
{
    public Vector3 ObjectSpawnPosition;
    public GameObject obj;
    public float SpawnRate = 1F;
    private float timestamp = 0F;
 
 
    void Update () 
    {
       if (Input.GetKeyDown(KeyCode.X) && Time.time >= timestamp)
       {
         Instantiate (obj, ObjectSpawnPosition, Quaternion.identity);
         timestamp = Time.time + SpawnRate;
       }
    }
}