Using keyboard keys to scroll via ScrollRect

I’ve set up my ScrollRect in the following way:

    public Scrollbar Horizontalscrollbar;
    public float scrollSpeed = 0.1f; // Adjust for desired scrolling speed
    
    void Update()
    {
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
        {
            Horizontalscrollbar.value += scrollSpeed;
        }
        else if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
        {
            Horizontalscrollbar.value -= scrollSpeed;
        }
        
        // Clamp the value to prevent going out of bounds
        Horizontalscrollbar.value = Mathf.Clamp01(Horizontalscrollbar.value);
    }

The scroll works fine with the keys but the issue I’m having is the selector. I have 5 buttons in the scroll but the selector (highlighted selection of button) goes of screen. This is hard to describe but let’s say the 1st button is selected (going from left to right), if I press the right arrow it goes to the 2nd button, if i press the left arrow to go back to the 1st button it goes back… but if I press the left arrow again, it goes off screen. I am wanting the selector to stay on screen and be clamped when it is on the 1st button and last button so it doesn’t go off screen. Please help if possible