arrows prevent scrolling

This commit is contained in:
Killian Marty 2023-12-09 12:03:03 +01:00
parent 3f3dc185b9
commit c1bb21a291

View file

@ -30,6 +30,9 @@ class Input {
});
window.addEventListener("keydown", (e)=>{
if(["Space","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
e.preventDefault();
}
this.keysDown.add(e.key.toLowerCase())
this.updateDir();
})
@ -43,7 +46,9 @@ class Input {
updateDir(){
if(player==null)
return;
let oldDir=this.dir;
this.dir=0;
if(this.keysDown.has('z') || this.keysDown.has('arrowup')){
if(this.keysDown.has('d') || this.keysDown.has('arrowright')){