How can ı change mouse click to Key in my script ?

I dont wanna activate code with mouse clicks. I want to press “W” for activate code. I am using proinput and things little bit complicated at now. How can ı change “rightButton” to “w” for keyboard ? First script is proinput script. Other is my original script which i want to change mouse click to “w”. Thanks for help…

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

namespace ProInput.Scripts {
    /// <summary>
    /// Main class of ProInput
    /// Outside classes should mainly invoke this class
    /// </summary>
    public class ProInput : MonoBehaviour {
        private static ProInput _proInput;
        private static bool _initialized;

        private Dictionary<string, InputObject> _enabledBindings;

        /// <summary>
        /// Initializes ProInput
        /// If already initialized, destroys object
        /// Doesn't destroy on load
        /// </summary>
        private void Awake() {
            // Checks if is initialized
            if (_initialized) {
                Destroy(gameObject);
                return;
            }

            // Initializes ProInput
            _initialized = true;
            _proInput = this;
            DontDestroyOnLoad(gameObject);
            _enabledBindings = new Dictionary<string, InputObject>();
        }

        /// <summary>
        /// Function called on update loop
        /// </summary>
        private void FixedUpdate() {
            var current = Keyboard.current;
            GetInputObjects().ForEach(o => o.Update(current));
        }
       
        /// <summary>
        /// Function called on application exit
        /// </summary>
        private void OnApplicationQuit() {
            GetInputObjects().ForEach(o => o.Save());
        }

        /// <summary>
        /// Converts dictionary to list
        /// </summary>
        /// <returns>InputObject list</returns>
        private List<InputObject> GetInputObjects() {
            return _enabledBindings.Values.ToList();
        }

        /// <summary>
        /// Add inputObject to bindings
        /// </summary>
        /// <param name="inputObject">New input</param>
        public static void RegisterInput(InputObject inputObject) {
            _proInput._enabledBindings.Add(inputObject.Name, inputObject);
        }
    }
}
using System;
using System.Diagnostics;
using Player;
using ProInput.Scripts;
using Rope;
using Unity.Collections;
using UnityEngine;

namespace Carriable.Carriables
{
    public class Shift : MonoBehaviour
    {
      
      
        private const float IDLE_FOV = 86f;
        private const float WALK_FOV = 85f;
        private const float SWİN_FOV = 109f;
        private const float RUN_FOV = 88f;
        private const float CROUCH_FOV = 78f;
        private const float NORMAL_FOV = 111f;
        private const float HOOKSHOT_FOV = 114f;
        public AudioClip _soundd;    // this lets you drag in an audio file in the inspector
        public AudioSource audioo;
        private CameraFov cameraFov;


        private float timer = 0f;

        public GameObject otherObject;
        Animator otherAnimator;
        void Start()
        {

            otherAnimator = otherObject.GetComponent<Animator>();
            audioo = audioo; //oadds an AudioSource to the game object this script is attached to
            audioo.playOnAwake = false;
            audioo.clip = _soundd;
            audioo.Stop();
            cameraFov = playerCamera.GetComponent<CameraFov>();
            speedLinesParticleSystem = transform.Find("Camera").Find("SpeedLinesParticleSystem").GetComponent<ParticleSystem>();





        }


        [Header("Grappling")]
        public GrapplingRope grapplingRope;
        public PlayerController player;
        public Transform grappleTip;
        public Transform grappleHolder;
        public int whatToGrapple;
        public float maxDistance;
        public float minDistance;
        public float rotationSmooth;
        public bool Swin;
        public bool Swinnn;
        public ParticleSystem speedLinesParticleSystem;
        public Camera playerCamera;




        [Header("Raycasts")]
        public float raycastRadius;
        public int raycastCount;

        [Header("Physics")]
        public float pullForce;
        public float pushForce;
        public float yMultiplier;
        public float minPhysicsDistance;
        public float maxPhysicsDistance;

        private Vector3 _hit;

        private void Update()
        {
            timer += Time.deltaTime;
        }

        private void FixedUpdate()
        {


            if (ProMouse.RightButton.IsPressed && grapplingRope.Grappling)
            {


                grappleHolder.rotation = Quaternion.Lerp(grappleHolder.rotation, Quaternion.LookRotation(-(grappleHolder.position - _hit)), rotationSmooth * Time.fixedDeltaTime);


                var distance = Vector3.Distance(player.transform.position, _hit);
                if (!(distance >= minPhysicsDistance) || !(distance <= maxPhysicsDistance)) return;

                if (timer >= 0.0063f)
                {
                    timer = 0f;

                    player.playerRigidBody.velocity += pullForce * Time.fixedDeltaTime * yMultiplier * Mathf.Abs(_hit.y - player.transform.position.y) * (_hit - player.transform.position).normalized;
                    player.playerRigidBody.velocity += pushForce * Time.fixedDeltaTime * player.transform.forward;

                }
            }
            else
            {
                grappleHolder.localRotation = Quaternion.Lerp(grappleHolder.localRotation, Quaternion.Euler(0, 0, 0), rotationSmooth * Time.fixedDeltaTime);
            }
        }


        private void LateUpdate()
        {
          
            if (this.otherAnimator.GetCurrentAnimatorStateInfo(0).IsName("Main Release"))
            {
                cameraFov.SetCameraFov(Main_FOV);
            }


            if (ProMouse.RightButton.IsDown && RaycastAll(out var hitInfo))
            {

                if (Input.GetButtonDown("left alt"))
                {
                    audioo.Play();

                }
                cameraFov.SetCameraFov(HOOKSHOT_FOV);



                speedLinesParticleSystem.Play();
                otherAnimator.SetBool("Swinnn", true);




                grapplingRope.Grapple(grappleTip.position, hitInfo.point);
                _hit = hitInfo.point;







            }



            if (ProMouse.RightButton.IsUp)
            {
                cameraFov.SetCameraFov(NORMAL_FOV);
                speedLinesParticleSystem.Stop();
                otherAnimator.SetBool("Swinnn", false);


                grapplingRope.UnGrapple();

            }




            if (ProMouse.RightButton.IsPressed && grapplingRope.Grappling)
            {



                otherAnimator.SetBool("Swinnn", true);

                grapplingRope.UpdateStart(grappleTip.position);




            }
            grapplingRope.UpdateGrapple();

        }

Check out the Input class, probably the GetKey() or GetKeyDown() methods.

This is input script. I am little bit confused about what i will change. Like i said i just wanna use “w” key instead mouse right click.

public class InputObject {
        // Default folder for bindings
        private const string BindingsFolder = "Bindings";
       
        // Handle used to save binding
        private readonly SaveHandle<BKey> _saveHandle;
        private readonly string _name;
        private Key _binding;

        private bool _isPressed;
        private bool _isDown;
        private bool _isUp;

        /// <summary>
        /// Constructor for InputObject
        /// </summary>
        /// <param name="name">Name of the input</param>
        /// <param name="defaultValue">Default binding</param>
        public InputObject(string name, Key defaultValue) {
            var directory = $"{Application.persistentDataPath}/{BindingsFolder}";
            if (!System.IO.Directory.Exists(directory))
                System.IO.Directory.CreateDirectory(directory);
           
            _name = name;
            _saveHandle = new SaveHandle<BKey>($"{BindingsFolder}/{name}_bind");

            var loadedData = _saveHandle.LoadData();
            _binding = loadedData ?? defaultValue;
            ProInput.RegisterInput(this);
        }

        /// <summary>
        /// Update input state
        /// </summary>
        /// <param name="current">Active keyboard</param>
        public void Update(Keyboard current) {
            var input = current.allKeys.First(control => control.keyCode == _binding);
            var pressed = input.isPressed;
            _isDown = !_isPressed && pressed;
            _isUp = _isPressed && !pressed;
            _isPressed = pressed;
        }

        /// <summary>
        /// Function called on application exit or saving
        /// </summary>
        public void Save() {
            _saveHandle.SaveData(_binding);
        }

        /// <summary>
        /// Bind input to new key
        /// </summary>
        public void Bind(Key key) {
            _binding = key;
            Save();
        }

        public string Name => _name;
        public bool IsPressed => _isPressed;
        public bool IsDown => _isDown;
        public bool IsUp => _isUp;
    }
}

Steps to success:

  1. identify in your code where you accept the click
  2. insert an additional check of the methods I suggested above to also accept the keypress
  3. act upon the click in precisely the same way regardless of how it arrived
// pseudocode, will NOT compile:
bool clicked = false;
if (mousehit) clicked = true;
if (keyhit) clicked = true;
if (clicked)
{
  DoTheThingIWant();
}

I think i am so close to solve. My question is how can ı activate script with double mouse click at same time. I want to press right and left at same time and activate code. Can you help me about that ?

 private void FixeddUpdate()
        {

           
            if (ProMouse.RightButton.IsPressed && ProMouse.LeftButton.IsPressed && grapplingRope.Grappling )
            {


                grappleHolder.rotation = Quaternion.Lerp(grappleHolder.rotation, Quaternion.LookRotation(-(grappleHolder.position - _hit)), rotationSmooth * Time.fixedDeltaTime);


                var distance = Vector3.Distance(player.transform.position, _hit);
                if (!(distance >= minPhysicsDistance) || !(distance <= maxPhysicsDistance)) return;

                if (timer >= 0.0063f)
                {
                    timer = 0f;

                    player.playerRigidBody.velocity += pullForce * Time.fixedDeltaTime * yMultiplier * Mathf.Abs(_hit.y - player.transform.position.y) * (_hit - player.transform.position).normalized;
                    player.playerRigidBody.velocity += pushForce * Time.fixedDeltaTime * player.transform.forward;


                }
            }
            else
            {
                grappleHolder.localRotation = Quaternion.Lerp(grappleHolder.localRotation, Quaternion.Euler(0, 0, 0), rotationSmooth * Time.fixedDeltaTime);
            }
        }


        private void LateUpdate()
        {
          
            if (this.otherAnimator.GetCurrentAnimatorStateInfo(0).IsName("Scene 0"))
            {
                cameraFov.SetCameraFov(Main_FOV);
            }


            if (ProMouse.RightButton.IsDown && ProMouse.LeftButton.IsDown && RaycastAll(out var hitInfo))
            {

                if (Input.GetButtonDown("Fire2"))
                {
                    audioo.Play();

                }
                cameraFov.SetCameraFov(HOOKSHOT_FOV);



                speedLinesParticleSystem.Play();
                otherAnimator.SetBool("Swinnn", true);




                grapplingRope.Grapple(grappleTip.position, hitInfo.point);
                _hit = hitInfo.point;



            }


            if (ProMouse.RightButton.IsUp && ProMouse.LeftButton.IsUp)
            {
                cameraFov.SetCameraFov(NORMAL_FOV);
                speedLinesParticleSystem.Stop();
                otherAnimator.SetBool("Swinnn", false);


                grapplingRope.UnGrapple();

            }




            if (ProMouse.RightButton.IsPressed && ProMouse.LeftButton.IsPressed && grapplingRope.Grappling)
            {



                otherAnimator.SetBool("Swinnn", true);

                grapplingRope.UpdateStart(grappleTip.position);


            }
            grapplingRope.UpdateGrapple();

        }

Double click can be done by making a float timer that you you count down every frame by Time.deltaTime;

When you click, check if that value is greater than zero. If so, consider it a double-click.

If not, then consider it a single-click and set that timer to the doubleclick interval.