I wrote the following script to download as pdf a google docs file; when I click alt+p nothing happens. I’m using Google Chrome browser.
Can you tell me how to fix it please?
(function() {
'use strict';
document.addEventListener('keydown', function(e) {
if (e.altKey && e.key === 'p') {
let fileId = window.location.pathname.split('/')[3];
let downloadUrl = `https://docs.google.com/document/d/${fileId}/export?format=pdf`;
window.open(downloadUrl, '_blank');
}
});
})();