Input help

I have this script that want to take a letter x as when the key x is pressed i want it to do this and that but I can not for the life of me figure out how to fix the input to handle this.I have been looking at this here for a while with not luck on understanding how to change this input x to call the script.

Thanks for any help

//damage of the attack
var slash = 1;

function Update () {

if (Input.GetButtonDown("x")){
//dice roll to see if attack hits
var dice = UnityEngine.Random.Range(1,50); 
//damage used for attack
var damage = slash * dice;
print("Slash");
print(damage);
return damage;
}
}

try Input.GetButtonDown(KeyCode.X)

that did it thanks a bucnch