title: How to detect a keypress event inside a function? Nodejs
body: <p>How can a keypress be detected only inside a function and not on all code?
  I have this code:</p>
  <pre><code>async function sellFunction() {
  
      let i = 0;
      let handle = setInterval(function() {
          logUpdate(&quot;Hello&quot; + i++)
      }, 100);
      gkm.events.on('key.*', async(data) =&gt; {
          if (gkm.events.event === 'key.released' &amp;&amp; (data[0] == 'A' || data[0] == 'B' || data[0] == 'C' || data[0] == 'D' || data[0] == 'F')) {
              clearInterval(handle);
              gkm.events.removeAllListeners();
              await init();
          }
      });
  
  }
  </code></pre>
  <p>The problem with this is that this key event is being detected even if im in another function.</p>