Skip to content

Instantly share code, notes, and snippets.

@jrr6
Last active September 18, 2022 20:18
Show Gist options
  • Select an option

  • Save jrr6/390b3ab81f28047f1c3efa0473297177 to your computer and use it in GitHub Desktop.

Select an option

Save jrr6/390b3ab81f28047f1c3efa0473297177 to your computer and use it in GitHub Desktop.
Adds arrow key and other useful shortcuts for navigating Google Calendar
// ==UserScript==
// @name GCalKeyboardShortcuts
// @version 1.0.3
// @description Adds arrow key and other useful shortcuts for navigating Google Calendar
// @author aaplmath
// @match https://calendar.google.com/calendar/*
// @downloadURL https://gist.github.com/jrr6/390b3ab81f28047f1c3efa0473297177/raw/GCalKeyboardShortcuts.user.js
// @updateURL https://gist.github.com/jrr6/390b3ab81f28047f1c3efa0473297177/raw/GCalKeyboardShortcuts.user.js
// @grant none
// ==/UserScript==
(function() {
document.body.addEventListener('keydown', (e) => {
// input takes care of most text fields; editable addresses block text entry (e.g., in event edit view)
if (document.activeElement.tagName === 'INPUT'
|| document.activeElement.classList.contains('editable')) return
if (e.keyCode === 37) { // left - previous
e.preventDefault()
e.stopPropagation()
document.querySelectorAll('.Ce1Y1c')[0].click()
} else if (e.keyCode === 39) { // right - next
e.preventDefault()
e.stopPropagation()
document.querySelectorAll('.Ce1Y1c')[1].click()
} else if (e.keyCode === 32) { // space - today
e.preventDefault()
e.stopPropagation()
document.querySelector('.VfPpkd-RLmnJb').click()
}
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment