How can i make a Horizontal selector with Keyboard and Gamepad navigation (Input System)

Hi, like the title says, i want to make the navigation with keyboard and mouse (Input System) so when i press left or right (A or D) it moves to the next or prev element(string, int, object…etc) in the list to swap, but so far i only made it work with the mouse by clicking in the buttons.

Here’s the code:

    public TMP_Text displayOptions;

    public string[] items = { "Item 1", "Item 2", "Item 3", "Item 4" };


    private int currentItem = 0;

    // Start is called before the first frame update
    void Start()
    {
        currentItem = PlayerPrefs.GetInt("currentItem");

        displayOptions.text = items[currentItem];
    }

    // Update is called once per frame
    public void NextButton()
    {
        currentItem++;

        //check if at the end of array
        if (currentItem > items.Length - 1)
        {
            currentItem = 0;
        }

        displayOptions.text = items[currentItem];

        PlayerPrefs.SetInt("currentItem", currentItem);
        PlayerPrefs.Save();
    }

    public void PreviousButton()
    {
        currentItem--;

        //check if at the end of array
        if (currentItem < 0)
        {
            currentItem = items.Length - 1;
        }

        displayOptions.text = items[currentItem];

        PlayerPrefs.SetInt("currentItem", currentItem);
        PlayerPrefs.Save();

Do you know how to set up inputs with the new input system? You’d just need to hook into input actions for A and D and have them call Next/Previous button.