add to an int on keypress

why is this not working? seems so simple. every time the E key is pressed I want to add 1 to my public int. But it goes from 0 to 4, then 8, then 6 then 10. seemingly random even values with no particular rhyme or reason

	public AudioClip beep;
	public int  mode = 0;


	void OnTriggerStay(Collider other) {
		if(other.tag == "Player")
		{
			if (Input.GetKeyDown(KeyCode.E))
			{
				audio.PlayOneShot(beep);
				mode += 1;
				
				

				}

If you want to only add one to the int once than just switch
mode += 1;
to
mode =+ 1;

I hope that helps, if you want to continually add once every time E is pressed, than your out of luck because I’m having the same problem and couldn’t find the answer anywhere.

actually , a similar problem occurs in a few of my other scripts as if it is registering the keydown more than once. I worked around it by adding an additional condition . So after it adds the 1 ( because adding is true) the next task it performs is making adding false

 void OnTriggerStay(Collider other) {
         if(other.tag == "Player")
         {
             if (Input.GetKeyDown(KeyCode.E))

{
Debug.Log (“true”);
adding =true;
{
if (adding ==true )
{
audio.PlayOneShot(beep);
mode += 1;
adding = false;
Debug.Log (“false”);
}
}