how would i make a slider that decreases when a key is down?

Hi I’m a beginner and was wondering how i could make a slider that decreases when a key is down. I am using this for a sprinting bar mechanic. I have something. Though it doesn’t decrease continually by 1, it only decreases once.

using UnityEngine;
using UnityEngine.UI;

public class shift : MonoBehaviour
    public Slider slider; 
    void Update()
            slider.value = slider.value - 1;


You must know the difference between thes 3 functions!!

GetKey() -> EVERY frame the key is pressed
GetKeyDown() -> ONE frame, the first frame is pressed
GetKeyUp() -> ONE frame, the last frame is pressed

You need to use GetKEy, not GetKeyDown!

Tip for future: Always you have problems like this, that you have a function that you think should do something, but its “not working”, go read the Unity manual, and 75% of times will find the solution!