title: how do i set a bool with key and make it like a switch
body: <p>i wanna make a script that opens photo mode by a key(in my case &quot;e&quot;) and holds it in open state until i press the key (e) again and i can't because it keeps updating it the code:</p>
  <pre><code>If (Input.GetKey(&quot;e&quot;))
        {
           Debug.Log(&quot;e&quot;);
           if (isphoto == true)
           {
  
               Debug.Log(&quot;true&quot;);
               MaxtimetoSwitch = 1;
               while (MaxtimetoSwitch &gt;= 1)
               {
                   isphoto = false;
                   MaxtimetoSwitch = MaxtimetoSwitch - 1;
  
  
               }
           }
           else
           {
               Debug.Log(&quot;false&quot;);
               MaxtimetoSwitch = 1;
               while (MaxtimetoSwitch &gt;= 1)
               {
                   isphoto = true;
                   MaxtimetoSwitch = MaxtimetoSwitch - 1;
  
               }
           }
           
               Debug.Log(&quot;false&quot;);
               MaxtimetoSwitch = 1;
               while (MaxtimetoSwitch &gt;= 1)
               {
                   isphoto = true;
                   MaxtimetoSwitch = MaxtimetoSwitch - 1;
  
          }
  </code></pre>