I need help with a getkey script

I need help with a script where when you input a key press a action is continuously done until a timer is done.

It’s hard to say what to do in your situation without some more context but the easiest way to do it is like this:

    float totalTime = 3;
    float currentTime = 3;

    private void Update()
        if (Input.GetKey(KeyCode.Space))
            currentTime = 0;


    void DoAction()
        if(currentTime < totalTime)
            //Your logic here

            currentTime += Time.deltaTime;

Note that depending on what you are doing this might be quite slow as it runs every frame.