1 year ago
#384681
skzao
How to detect a keypress event inside a function? Nodejs
How can a keypress be detected only inside a function and not on all code? I have this code:
async function sellFunction() {
let i = 0;
let handle = setInterval(function() {
logUpdate("Hello" + i++)
}, 100);
gkm.events.on('key.*', async(data) => {
if (gkm.events.event === 'key.released' && (data[0] == 'A' || data[0] == 'B' || data[0] == 'C' || data[0] == 'D' || data[0] == 'F')) {
clearInterval(handle);
gkm.events.removeAllListeners();
await init();
}
});
}
The problem with this is that this key event is being detected even if im in another function.
javascript
node.js
keypress
onkeypress
0 Answers
Your Answer