Created
October 24, 2016 18:43
-
-
Save rodneyrehm/242ccab2876b549ee6ae4f3cd5baec3b to your computer and use it in GitHub Desktop.
Zencastr Keyboard Toggle Microphone Mute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?