arrows prevent scrolling
This commit is contained in:
parent
3f3dc185b9
commit
c1bb21a291
1 changed files with 6 additions and 1 deletions
|
@ -30,6 +30,9 @@ class Input {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("keydown", (e)=>{
|
window.addEventListener("keydown", (e)=>{
|
||||||
|
if(["Space","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].indexOf(e.code) > -1) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
this.keysDown.add(e.key.toLowerCase())
|
this.keysDown.add(e.key.toLowerCase())
|
||||||
this.updateDir();
|
this.updateDir();
|
||||||
})
|
})
|
||||||
|
@ -43,7 +46,9 @@ class Input {
|
||||||
updateDir(){
|
updateDir(){
|
||||||
if(player==null)
|
if(player==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let oldDir=this.dir;
|
let oldDir=this.dir;
|
||||||
|
|
||||||
this.dir=0;
|
this.dir=0;
|
||||||
if(this.keysDown.has('z') || this.keysDown.has('arrowup')){
|
if(this.keysDown.has('z') || this.keysDown.has('arrowup')){
|
||||||
if(this.keysDown.has('d') || this.keysDown.has('arrowright')){
|
if(this.keysDown.has('d') || this.keysDown.has('arrowright')){
|
||||||
|
|
Loading…
Reference in a new issue