mirror of
https://github.com/danbulant/arcade-machine
synced 2026-07-06 19:40:35 +00:00
Added configurable menu keys to Vars.js
This commit is contained in:
parent
66e9123835
commit
52a68e67b6
1 changed files with 16 additions and 13 deletions
|
|
@ -49,20 +49,23 @@
|
||||||
</audio> -->
|
</audio> -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
const prvnihra = [...document.querySelectorAll("button")]
|
const prvnihra = [...document.querySelectorAll("button")]
|
||||||
// for (i = 0; i < prvnihra.length; i++) {
|
// for (i = 0; i < prvnihra.length; i++) {
|
||||||
//console.log(prvnihra[i]);
|
//console.log(prvnihra[i]);
|
||||||
//}
|
//}
|
||||||
console.log(prvnihra[0])
|
console.log(prvnihra[0])
|
||||||
prvnihra[0].focus();
|
prvnihra[0].focus(); /* Handles interaction with bindable buttons and focus*/
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
/**/
|
||||||
var i = 0;
|
var i = 0;
|
||||||
const switchfocus = new Audio("Audio/switchfocus.mp3");
|
const switchfocus = new Audio("Audio/switchfocus.mp3");
|
||||||
const startaudio = new Audio ("Audio/audiostart.mp3")
|
const startaudio = new Audio("Audio/audiostart.mp3")
|
||||||
document.addEventListener("keydown",function(sex2){
|
document.addEventListener("keydown", function (KeypressD) {
|
||||||
if (sex2.code === "KeyD"){
|
if (KeypressD.code === KeyRight) {
|
||||||
if(i>=prvnihra.length - 1) i = -1;
|
if (i >= prvnihra.length - 1) i = -1;
|
||||||
switchfocus.play();
|
switchfocus.play();
|
||||||
i++;
|
i++;
|
||||||
prvnihra[i].focus();
|
prvnihra[i].focus();
|
||||||
|
|
@ -70,30 +73,30 @@
|
||||||
console.log("array je", prvnihra.length);
|
console.log("array je", prvnihra.length);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
document.addEventListener("keydown",function(sex3){
|
document.addEventListener("keydown", function (Keypress) {
|
||||||
if(sex3.code === "KeyA"){
|
if (Keypress.code === KeyLeft) {
|
||||||
switchfocus.play();
|
switchfocus.play();
|
||||||
if(i<=0) i=prvnihra.length
|
if (i <= 0) i = prvnihra.length
|
||||||
i--;
|
i--;
|
||||||
prvnihra[i].focus()
|
prvnihra[i].focus()
|
||||||
console.log("left", i);
|
console.log("left", i);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (sex3.code === "KeyE"){
|
if (Keypress.code === KeyStart) {
|
||||||
startaudio.play();
|
startaudio.play();
|
||||||
console.log(document.activeElement);
|
console.log(document.activeElement);
|
||||||
document.activeElement.click();
|
document.activeElement.click();
|
||||||
}
|
}
|
||||||
if(sex3.code === "KeyS" && i+3 < prvnihra.length){
|
if (Keypress.code === KeyDown && i + 3 < prvnihra.length) {
|
||||||
switchfocus.play();
|
switchfocus.play();
|
||||||
console.log(i);
|
console.log(i);
|
||||||
i = i+3;
|
i = i + 3;
|
||||||
prvnihra[i].focus();
|
prvnihra[i].focus();
|
||||||
}
|
}
|
||||||
if(sex3.code === "KeyW" && i-3 >= 0){
|
if (Keypress.code === KeyUp && i - 3 >= 0) {
|
||||||
switchfocus.play();
|
switchfocus.play();
|
||||||
console.log(i);
|
console.log(i);
|
||||||
i = i-3;
|
i = i - 3;
|
||||||
prvnihra[i].focus();
|
prvnihra[i].focus();
|
||||||
}
|
}
|
||||||
//document.body.requestFullscreen();
|
//document.body.requestFullscreen();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue