I have been running the following code using es6 babel on chrome:
window.hold = [];
window.addEventListener('keydown', (e) => {
if (!window.hold.includes(e.key)) {
setTimeout(() => {
console.log("> - " + e.key);
window.hold.push(e.key);
}, 0);
} else { e.preventDefault(); }
});
window.addEventListener('keyup', (e) => {
setTimeout(() => {
console.log("< - " + e.key);
window.hold.splice(window.hold.indexOf(e.key), 1);
e.preventDefault();
}, 0);
});
If I hold ASDZ on the keyboard, it doesn't log the Z, but if I hold ASDK, it logs everything as it should, does anyone know why this is happening?