GetButtonDown / GetButtonUp usage c#

thanks for your time. i’m new to c# & trying to figure out how GetButtonDown / GetButtonUp is used,
asking why the following code does not work. don’t get errors to display i’m doing anything wrong. i’ve also already have the tag added to my input.

using UnityEngine;

using System.Collections;

public class ChargingLogic : MonoBehaviour
{

public bool isCharging = false;
public string textToDisplay = "Click";
//
void Update ()
{
	if (Input.GetButtonDown (textToDisplay) && !isCharging)
		Debug.Log ("GetButtonDown textToDisplay");
		isCharging = true;
	if (Input.GetButtonUp (textToDisplay))
		Debug.Log ("GetButtonUp textToDisplay");
		isCharging = false;
  
}

void OnGUI ()
{	
	if (GUI.Button(new Rect(10,70,50,30),textToDisplay))
           Debug.Log("Clicked the GUI button");
}



void Charge ()
{
	if (isCharging) {
		Debug.Log ("Charging");
	} else {
		Debug.Log ("Not Charging");
	
	}
}

}

You are misled by Input.GetButtonDown ! It doesn’t relate to OnGUI buttons, but to predefined keyboard or joystick input such as “Fire1”.

OnGUI buttons are only triggered when you release the click. Use a repeat button for a click and hold behaviour!

From the docs :

function OnGUI () {
if (GUI.RepeatButton (Rect (25, 25, 100, 30), "RepeatButton")) {
	// This code is executed every frame that the RepeatButton remains clicked
}

}