How To Play A Sound On Key Press In Javascript?
I'm trying to write my JavaScript code so that a sound plays only when a certain key is pressed. The HTML code I am trying to associate it with is:
Solution 2:
After Some Minor Modifying You can use the specified key as a trigger for the Audio Clip
if (e.keyCode == 65) {
if(document.getElementById('audio').paused){
document.getElementById('audio').play();
}
else{
document.getElementById('audio').pause;
}
});
Here it will work as a trigger for the Audio file.. Credit: Andreas Moldskred
Post a Comment for "How To Play A Sound On Key Press In Javascript?"