sinanisler logo

Video Volume – Mute / Unmute / Toggle (M key)

change the “.mute-unmute” button and “.video-hero” video selectors depending on your setup.

document.querySelector('.mute-unmute').addEventListener('click', toggleMute);

document.addEventListener('keydown', function(event) {
  if (event.key === 'm' || event.key === 'M') {
    toggleMute();
  }
});

function toggleMute() {
  var video = document.querySelector('.video-hero');
  video.muted = !video.muted;
}

Leave the first comment