Skip to content

Instantly share code, notes, and snippets.

@awatertrevi
Last active June 21, 2022 23:12
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 awatertrevi/4149c10f4511ef99eb351e8b2197beb7 to your computer and use it in GitHub Desktop.
Save awatertrevi/4149c10f4511ef99eb351e8b2197beb7 to your computer and use it in GitHub Desktop.
Cmd + Enter = Save on Google Calendar #tampermonkey
// ==UserScript==
// @name Google Calendar (Cmd + Enter = Save)
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Saves a calendar event when Cmd + Enter is pressed.
// @author Trevi Awater
// @match https://calendar.google.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let isHoldingCmd = false;
document.addEventListener('keydown', keyDown);
document.addEventListener('keyup', keyUp);
function keyDown (e) {
if (e.code === 'MetaLeft') {
isHoldingCmd = true;
}
else if (e.code === 'Enter' && isHoldingCmd) {
document.getElementById('xSaveBu').click();
}
}
function keyUp (e) {
if (e.code === 'MetaLeft') {
isHoldingCmd = false;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment