Recently I run into an odd bug, I'm not sure if this is my code bug or is it a problem in JS/Rust Web Assembly.
Long story short I have been trying to call an web assembly async function from js event handler, for some reason the event is keep triggering infinite times. for example for the 'keydown' event once you press a key the handler will be called (You can release the key and it still thinks that you are pressing it) until you switch tab.
code example:
Rust function:
[wasm_bindgen]
pub async fn test() {
await something();
}
js code:
import the wasm...
document.addEventListener('keydown', keyDownHandler, false)
function keyDownHandler() {
test();
}
What do you advise me to do? Should I reported it as a bug in the wasm community? Maybe you have a solution for me?