I have started to program in Javascript to make a 3D application with WebGL. I need to receive the keyboard inputs in an other way, because the way I do it, like this:
var keys = {};
window.addEventListener("keydown", (e) => {
keys[e.which] = true;
updateKeys();
});
window.addEventListener("keyup", (e) => {
delete keys[e.which];
updateKeys();
});
function updateKeys() {
for(var i in keys) {
if(keys[87] === true) {
//Move
}
}
}
produces a very rough result and there is stuttering. Is there some way I can get a smooth input?