Skip to content

Instantly share code, notes, and snippets.

@MikeRawding
Last active March 9, 2021 19:33
Show Gist options
  • Save MikeRawding/de001c0c37e9fb550cb53107c93f4b27 to your computer and use it in GitHub Desktop.
Save MikeRawding/de001c0c37e9fb550cb53107c93f4b27 to your computer and use it in GitHub Desktop.
Tampermonkey script to add PTT to google meet.
// ==UserScript==
// @name Google Meet Spacebar PTT
// @namespace https://github.com/mikerawding
// @version 0.1
// @description Use Spacebar as Push-To-Talk for Google Meet
// @author Mike Rawding
// @match https://meet.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const hotKey = 'Space'
let hotKeyDown = false
const toggleMute = () => {
document.dispatchEvent(
new KeyboardEvent("keydown", {
key: "d",
keyCode: 68,
code: "KeyD",
which: 68,
ctrlKey: true,
})
)
}
window.addEventListener('keydown', event => {
if (event.code === hotKey && document.querySelector('[data-is-muted="true"]') && !hotKeyDown) {
hotKeyDown = true
toggleMute()
}
})
window.addEventListener('keyup', event => {
if (event.code === hotKey && document.querySelector('[data-is-muted="false"]')) {
hotKeyDown = false
toggleMute()
}
})
})();
@MikeRawding
Copy link
Author

Done, thanks.

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