title: How to avoid google sheet script not recording newly input value if cells stays highlighted?
body: <p>I've noticed that a google sheet script doesn't execute properly if an inexperienced user leaves an input cell highlighted after inputting a new value.</p>
  <p>That could be manually solved by clicking the ENTER key on the keyboard, or some other key, then running the script; so I thought a way around was to mimic a keyboard input, but I'm unsure if there's any better solution.</p>
  <p>As an example, I'd like the script to execute the &quot;ENTER&quot; key, before and after it executes the test multiplying function, as in the following test sheet:
  <a href="https://docs.google.com/spreadsheets/d/1TMjakai_5b_UHhXHSu3TWJeI7saAeQd64H6WYWDNHfE/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1TMjakai_5b_UHhXHSu3TWJeI7saAeQd64H6WYWDNHfE/edit?usp=sharing</a></p>
  <p>The script I'm using for a test is the following:</p>
  <pre><code>    function Test() { 
      var ss = SpreadsheetApp.getActiveSpreadsheet(); 
      var formS = ss.getSheetByName(&quot;Data&quot;); 
      var y = formS.getRange(&quot;A3&quot;).getValue();
      var z = formS.getRange(&quot;B3&quot;).getValue();
      var x = y * z;
      formS.getRange(&quot;E3&quot;).setValue(x);
    }
  
  </code></pre>
  <p>Anyone can try it on google sheet: just click (once or twice) on either cell A3 or B3, leaving them highlighted, and click the button to execute the script.
  Without clicking outside the cell or using ENTER by keyboard, the script won't record the newly inputted value.</p>
  <p>Is there a better way to do it?</p>