Call function based off enum state?

So im working on a game that has the player use a variety of items, all tied to the same 3 keys (i.e. if itemKey1 has the greatsword state, then pressing itemKey1 will use the greatsword). at the moment i have an input handler class that stores the state and checks for input, it then calls a function in my “UseItem” class, and in that, it checks, in a series of if statements, what item is selected, then calls a different function depending.

public enum ItemType 
{
    rapier, greatsword, bow
}
public class InputHandler : MonoBehaviour
{
    [Header("INPUTS")]
    public static KeyCode itemKey1 = KeyCode.J;
    public static KeyCode itemKey2 = KeyCode.K;
    public static KeyCode itemKey3 = KeyCode.L;

    public static KeyCode runKey = KeyCode.LeftShift;

    [Header("ENUMS")]
    public ItemType item1;
    public ItemType item2;
    public ItemType item3;

    [Header("SCRIPT REFERENCES")]

    UseItem use;

    private void Start()
    {
        use = FindObjectOfType<UseItem>();
    }

    private void Update()
    {
        InputItem();
    }
    void InputItem()
    {
        if (Input.GetKeyDown(itemKey1))
        {
            use.InputUse(item1);
        }

        if (Input.GetKeyDown(itemKey2))
        {
            use.InputUse(item2);
        }

        if (Input.GetKeyDown(itemKey3))
        {
            use.InputUse(item3);
        }
    }
}

public class UseItem : MonoBehaviour
{
    RapierAttack rapier;
    GreatswordAttack greatsword;
    PlayerBow bow;
    private void Start()
    {
        rapier = GetComponent<RapierAttack>();
        greatsword = GetComponent<GreatswordAttack>();
        bow = GetComponent<PlayerBow>();
    }

    public void InputUse(ItemType item)
    {
        if(item == ItemType.rapier)
        {
            if(rapier.canUse)
                rapier.Use();
        }
        else if(item == ItemType.greatsword)
        {
            if (greatsword.canUse)
                greatsword.Use();
        }else if(item == ItemType.bow)
        {
            bow.Use();
        }
    }
}

This all works, but my concern is that it isnt very expandable. i would like to call one function that is overidden by the specific Use() function that is applicable. Ive heard about abstract classes, but i dont really understand them. would scriptable objects be of any use?
Sorry for the really long question, any help is welcome!

Hello there,

this use case is the exact reason what Object Oriented Programming is for.
You idea that your current approach with cause issues down the road is exactly correct. What you want to do here is the following:

Change your current UseItem class into this format:

public class UsableItem : MonoBehaviour
    {
        public virtual void UseItem()
        {
            throw new System.NotImplementedException("This function must not be called. It must be overridden.");    
        }
    }

    //example for your Bow:
    public class Bow : UsableItem
    {
        public override void UseItem()
        {
            //do whatever you need to do to use your bow
        }
    }
    //example for a Sword:
    public class Sword : UsableItem
    {
        public override void UseItem()
        {
            //do whatever you need to do to use your sword
        }
    }

Both the Bow and Sword class can now be stored in a UsableItemreference. In addition they each call their respective UseItem function when being called upon.
Based on this you could just store a direct reference to an usable Item in your InputControl script:

public class InputControl : MonoBehaviour
    {
        [Header("INPUTS")]
        public static KeyCode[] slotKeys = {
            KeyCode.J,
            KeyCode.K,
            KeyCode.L
        };

        public UsableItem[] ItemSlots = new UsableItem[slotKeys.Length];

        public void Update()
        {
            for(int i=0;i<slotKeys.Length;i++)
            {
                if(Input.GetKeyDown(slotKeys*))*

{
if (ItemSlots != null)
ItemSlots*.UseItem();*
}
}
}
}
This way you have an easy way to extend your slots by simply adding another key.
You can additionally add more weapon behaviours in a really easy way.
Let me know if that helped or if something was unclear.