I want to call a function, if a key was released, because I program a little Jump'n'Run and for that I have to know that, because if I use a "normal" handler which is called if a key is pressed, it don't works, because the handler is not called often enough.
I don't want to use jquery or something else, only native JavaScript.
Thank you in advance.
Checkout the snipper below. I think this is all you're looking for.
document.addEventListener('keyup', (event) => {
const keyName = event.key;
alert('keyup event\n\n' + 'key: ' + keyName);
});
MDN documentation for keyup event
document.getElementById('myField').addEventListener('keyup', e => {
console.log(`keyup event fired for key: ${e.key}`);
});
Type here: <input id="myField" type="text" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With