Skip to content

Instantly share code, notes, and snippets.

@rodneyrehm
Created October 24, 2016 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodneyrehm/242ccab2876b549ee6ae4f3cd5baec3b to your computer and use it in GitHub Desktop.
Save rodneyrehm/242ccab2876b549ee6ae4f3cd5baec3b to your computer and use it in GitHub Desktop.
Zencastr Keyboard Toggle Microphone Mute
var container = document.querySelector('.lobby-user');
var unmutedIcon = document.querySelector('.user-meta .status .unmuted');
var mutedIcon = document.querySelector('.user-meta .status .muted');
var control = document.querySelector('.user-meta .status');
control.setAttribute('role', 'button');
control.setAttribute('tabindex', 0);
control.setAttribute('accesskey', 'm');
control.addEventListener('keydown', function(event) {
event.preventDefault();
if (event.keyCode === 13 || event.keyCode === 32) {
var event = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
});
if (container.classList.contains('muted')) {
unmutedIcon.dispatchEvent(event);
} else {
mutedIcon.dispatchEvent(event);
}
}
}, false);
@joshontheweb
Copy link

I'll take this as a vote for more hotkeys lol ;)

I haven't implemented something like this so far because I've been worried that people will press m by accident and unintentionally mute themselves. Maybe + m or something like that would be more feasible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment