How do I use Input.GetButton, instead of OnMouse()

I realize this question may be “silly” but I’m new to C#. I’m using this script example i found for a keypad:

void Update () {
Debug.Log (playerCode);

	if (totalDigits == 4)
			playerCode = null;
			theDoor.GetComponent<Animation> ().Play ();
			theDoor.GetComponent<AudioSource> ().Play ();
			Debug.Log ("Correct");

			totalDigits = 0;
			Debug.Log ("Wrong");
void OnMouseUp()
	GameObject.FindWithTag ("KeypadButton");
	playerCode +=;	
    totalDigits += 1;
    keySound.GetComponent<PlaysoundScript> ().Clicky ();

This script works fine in the editor when using the mouse, But I want the “OnMouseUp Click” to be done with a gamepad button in the Input manager

I tried moving the OnMouseUp() function inside Update, adding Raycast etc.
What am I missing?
Any help would be appreciated, Thanks.

I don’t know how to do exactly what you need but i have an alternative. I always use the key up bool to check if a key is up.


simply fill in the key/button you are checking and if it is true just call a OnMouseup . You may need to make a new method name if doing this



I hope this answer is what your looking for. It should at least get you going if your still stuck