Next/Previous navigation with arrow keys!

Use the arrow keys to navigate the next or previous pages of tutorials ;)

Version vom 05.03.2025. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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/Previous navigation with arrow keys!
// @namespace   Violentmonkey Scripts
// @match       https://www.w3schools.com/*/*
// @grant       none
// @version     1.1
// @author      AvinashReddy3108 (assisted by ChatGPT)
// @license     WTFPL
// @description Use the arrow keys to navigate the next or previous pages of tutorials ;)
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(event) {
        if (event.target.tagName.toLowerCase() === 'input' || event.target.tagName.toLowerCase() === 'textarea') {
            return; // Ignore inputs and textareas
        }

        // Container which has the next/previous buttons
        let container = document.querySelector("div.w3-clear.nextprev");
        if (!container) return;

        // The Next/Previous buttons
        let prevButton = container.querySelector("a.w3-left.w3-btn");
        let nextButton = container.querySelector("a.w3-right.w3-btn");

        if (event.key === 'ArrowLeft' && prevButton) {
            window.location.href = prevButton.href;
        } else if (event.key === 'ArrowRight' && nextButton) {
            window.location.href = nextButton.href;
        }
    });
})();