I have a sound that is 2 seconds long. It is bound to the enter key. I want to be able to press the enter key multiple times per second enabling multiple layers of the same sound.
Currently I can initiate the sound, but the next one won't play until the first one is finished.
This is the code that I have that works but does not layer the sounds upon multiple keypresses:
var fart = new Audio('http://www.soundjay.com/human/fart-01.wav');
$(document).keydown(function(e) {
if(e.keyCode == 13)
{
fart.play();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Click here then press enter.
This looked like it might contain the answer, but I wasn't able to get any executable code that worked for me: Sound effects in JavaScript / HTML5