to change "Fire1" to "Fire2" by public variable

I am not a programmer so could someone help me?
I have weapon controller script with this line:

if (Input.GetButton(“Fire1”) && Time.time > nextFire)

What I want is to change “Fire1” to “Fire2” by public variable. Is it possible?


public string axis = "Fire1";

void Update()
  if (Input.GetButton(axis) && Time.time > nextFire)

If I am not mistaken, you are unable to change the Input keys via scripting.

But if you need to access them publicly (from editor), you can find them under: Edit > Project Settings > Input