How can I use both mouse and keyboard to do the same thing? [SOLVED]

Hello!

I’ve just finished the Breakout Game tutorial and I want to move my paddle object with both keyboard and mouse. I want the player to choose which one he/she wants.

public float paddleSpeed = 1f;

private Vector3 playerPos = new Vector3 (0, -9.9f, 0);

// Update is called once per frame
void Update () {

	float xPos = transform.position.x + (Input.GetAxis ("Mouse X") * paddleSpeed);
	playerPos = new Vector3 (Mathf.Clamp (xPos, -7.5f, 7.5f), -9.9f, 0f);
	transform.position = playerPos;

	}

}

I’ve discovered how to move with my mouse but how can I add ‘Input.GetAxis (“Horizontal”)’ into the script? And how can I hide my mouse pointer?

using UnityEngine;
public class asd : MonoBehaviour
{

    public float paddleSpeed = 1f;
    private Vector3 playerPos = new Vector3(0, -9.9f, 0);
    bool mouseMoves;
    void Start() {
        Cursor.visible = false;
    }
    void Update()
    {

        float m = Input.GetAxis("Mouse X");
        float h = Input.GetAxis("Horizontal");  
        float[] t = {m,h};                      
        for (int i = 0; i < t.Length; i++) {
            if (t[0] != 0)
            {
                mouseMoves = true;
                float xPos = transform.position.x + t[0] * paddleSpeed;
                playerPos = new Vector3(Mathf.Clamp(xPos, -7.5f, 7.5f), -9.9f, 0f);
                transform.position = playerPos;
            }
            
            else if(t[1] != 0 && !mouseMoves)
            {
                float xPos = transform.position.x + t[1] * paddleSpeed;
                playerPos = new Vector3(Mathf.Clamp(xPos, -7.5f, 7.5f), -9.9f, 0f);
                transform.position = playerPos;
            }
            else
            {
                mouseMoves = false;
            }
        } 
    }
}

or Simply :

using UnityEngine;
public class asd : MonoBehaviour
{

    public float paddleSpeed = 1f;
    private Vector3 playerPos = new Vector3(0, -9.9f, 0);
    bool mouseMoves;
    void Start()
    {
        Cursor.visible = false;
    }
    void Update()
    {

        if (Input.GetAxis("Mouse X") != 0)
        {
            mouseMoves = true;
            float xPos = transform.position.x + Input.GetAxis("Mouse X") * paddleSpeed;
            playerPos = new Vector3(Mathf.Clamp(xPos, -7.5f, 7.5f), -9.9f, 0f);
            transform.position = playerPos;
        }

        else if (Input.GetAxis("Horizontal") != 0 && !mouseMoves)
        {
            float xPos = transform.position.x + Input.GetAxis("Horizontal") * paddleSpeed;
            playerPos = new Vector3(Mathf.Clamp(xPos, -7.5f, 7.5f), -9.9f, 0f);
            transform.position = playerPos;
        }
        else
        {
            mouseMoves = false;

        }
    }
}