I would like to know how to use IMAGE in CANVAS as a handle to move it only left and right on the mo

When playing in a 2D mobile environment

I want the player I created to only move left and right.

I created an Input system like this:


So, I created inputActions and wrote the player script as follows.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Windows;

public class PlayerMovement : MonoBehaviour
{
   ...

   [SerializeField] private InputActionReference moveActionToUse;

   ...

   void Update()
   {
       Vector2 moveDirection = moveActionToUse.action.ReadValue<Vector2>();
       float input = moveDirection.x;
        ...
   }

   void FixedUpdate()
   {

       ...

   }
}

Here, the player succeeded in only moving left and right.
The Handle image on the Canvas can be moved in all directions.
Is there a way to make the Handle move only left and right on the X axis on the mobile screen?
Very Thanks