i am coding a full air horn piano for me and my friends (kind of dumb i know) and i got to doing all the key binds and then i ran into this problem, the sounds wont stop when i release the key that was pressed to activate it.
here is what i have so far in the .js file(just one sound put in so far):
function startAnatural(){
var A = new Audio("A natural.mp3");
A.play();
}
function stopAnatural(){
var A = new Audio("A natural.mp3");
A.pause();
A.currentTime = 0;;
}
document.onkeydown = function(e){
e = e || window.event;
var key = e.which || e.keyCode;
if(key===81){
startAnatural();
}
};
document.onkeyup = function(e){
e = e || window.event;
var key = e.which || e.keyCode;
if(key===81){
stopAnatural();
}
};