I'm trying to set a TamperMonkey script to make a keyboard key pause the native Chrome video player without the need to click on it or use the Space Bar
To achieve this, I tried to set a script that would trigger the click action in an x, y coordinate where the video is displayed on the page.
So far, it didn't work.
// PAUSE VIDEO - ASSIGNED TO *Q* KEY
(function(){
document.addEventListener('keydown', function(e) {
if (e.keyCode == 81 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
document.elementFromPoint(448, 540).click(); // this should trigger the click on video to pause event
}
}, false);
})();
Can anyone enlighten me on how to make this video pause with the key Q?