Next and Previous key shortcuts for Spotify

Allows the left and right keyboard arrows to be used to go to the previous and next songs on Spotify.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Next and Previous key shortcuts for Spotify
// @description  Allows the left and right keyboard arrows to be used to go to the previous and next songs on Spotify.
// @author       Zach Saucier
// @namespace    https://zachsaucier.com/
// @version      1.1
// @match        https://open.spotify.com/*
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('keydown', (event) => {
        switch(event.code) {
            case 'ArrowLeft':
                document.querySelector('.spoticon-skip-back-16').click();
                break;
            case 'ArrowRight':
                document.querySelector('.spoticon-skip-forward-16').click();
                break;
        }
    }, false);
})();