Start timer with Input

I want to make a 2d shooter in wich, if you hold a button, the player will fire constantly in a cycle (like a delay between each bullet). So when I hold the button, I would like a timer (or a clock) to start and when I stop holding it, I would like the timer to stop.
I’m quite new to Unity, so I don’t know a lot of things, maybe you can help me.
PS: I use javascript the most, but I can get my head around c#.
Thank you.

Put your firing script in a method. Call it from InvokeRepeating to put on the auto-fire, and use CancelInvoke to turn it off.

Input.GetButtonDown() tells you when a button is first pressed. So, use a variable to store the current time, from Time.time. Input.GetButton() will tell you when that button is held down. So, compare current time with the stored time. If that meets you time delta then do your thing. You might want to add your time delta to the stored time value, so all you ever need do is look to see if now time minus your stored time is greater than your delta. When Input.GetButtonUp() happens, then you know your looping is done.