Deactivate Key.

So basically I made a script where when the “G” key is Held it plays an animation and disables the Polygon Collider 2d, and I made another script that basically allows you to run or walk. How do I make it when other Keys are being pressed or held then if the G key is held it does nothing.

-So basically how can I make so if player is pressing/holding other Keys then the “G” key won’t activate’

private bool disableG; // this will be set to true or false
private void Start()
{
disableG = false;// we start it at false
}
private void Update () {
if (Input.anyKeyDown) // if you press down any key
{
if (!Input.GetKeyDown(KeyCode.G)) //and that key isn’t g
{
disableG = true; //disable g is set to true
}
}
if (!Input.anyKey) //if you’re not pressing anything
{
disableG = false; //disable g is set to true, this will ensure if you press and release a button you’ll be able to press g again even if it’s in a single fram
}
if (Input.GetKeyDown(KeyCode.G) && disableG == false) //now we see if you’re pressing g and it hasn’t been disabled by pressing another button
{
//do stuff
}
}

As simple as:

if (!Input.GetKey(KeyCode.G))
 {
         //do nothing or return
}

,As simple as:
if (!Input.GetKey(KeyCode.G))
{
//do nothing or return
}