Hi,
i would like to have an event by clicking enter once and an other event by clicking enter twice.
It looks like this:
//close info texts with ENTER
if(close_btn.visible){
this.input.keyboard.once("keydown-" + "ENTER", () => {
buttonAudio.play();
fInfoGroup.setVisible(false);
if(infoteam_EG.visible){
fSpotsGroup_EG.setVisible(true);
fSpotsGroup_1OG.setVisible(false);
fSpotsGroup_2OG.setVisible(false);
} else if (infoteam_1OG.visible) {
fSpotsGroup_EG.setVisible(false);
fSpotsGroup_1OG.setVisible(true);
fSpotsGroup_2OG.setVisible(false);
} else if(infoteam_2OG.visible) {
fSpotsGroup_EG.setVisible(false);
fSpotsGroup_1OG.setVisible(false);
fSpotsGroup_2OG.setVisible(true);
} else {
return;
}
close_btn.setVisible(false);
tutor.setVisible(false);
});
}
let lastTime = 0;
this.input.keyboard.on("keydown-" + "ENTER", ()=>{
let clickDelay = this.time.now - lastTime;
lastTime = this.time.now;
if(clickDelay < 350) {
this.scene.start("Instructions");
}
});
It general works but when i press ENTER too long it also acts like its double click.
Can i proof if the key is really pressed twice and not once but a longer time?
Thanks!