I have a small problem, I made a piano using JavaScript in the browser and it's working with the keyboard keys. i need only javascript, jquery is not an option for me right now.
The issue is when I hold a key, the noise sound keeps on repeating itself and I want it to play only once per key I press even when I hold it for couple of seconds.
How can I do that?
<audio id="do">
<source src="do.mp3" type="audio/mp3"></audio>
<script>
var do1 = document.getElementById('do');
function load1()
{
do1.load();
}
document.addEventListener('keydown',function(event) {
if(event.keyCode == 90) {{do1.load()
do1.play();
}}
});
</script>