I'm trying to play a sound when I hit the b key, but i cant seem to figure it out
HTML:
<audio id="music">
<source src="asap.mp3" type="audio/mpeg">
</audio>
JS:
var s2 = document.getElementById('music')
document).keydown(function(e){
if (e.keyCode == 66) {
s2.play();
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…