How to use buttons with keys

I am having a little trouble with my c# game, i am trying to make a battle system and i have to click on the buttons to make them work. I was wondering if there was any way I could use keys like Z and X to make those buttons work

Use the Input class Instead of the Input Axis.

So in some Component related to the button you would have:

void Update(){
   if (Input.GetKey(KeyCode.Z)){
      //Run some code here
   }
}

Here’s the relevant Documentation:

You want to look at GetKey, GetKeyDown and GetKeyUp because they all do slightly different things.

You might want to look also at Input Manager

Using Input Manager axes will allow your players to change controls to what they prefer. Even though this system is less obvious then explicit specifying the keys.

Using axes values is described here: