Disable reddit keyboard shortcuts

Disables keyboard shortcuts on reddit

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Disable reddit keyboard shortcuts
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Disables keyboard shortcuts on reddit
// @author       You
// @match        https://www.reddit.com/*
// @match        https://new.reddit.com/*
// @grant        none
// @license      mit
// ==/UserScript==

(function() {
    'use strict';

    // Function to override keyboard event listeners
    function overrideKeyboardEvents() {
      function stopEvent(e) {
        e.stopImmediatePropagation();
      }

      window.addEventListener('keydown', stopEvent, true);
      window.addEventListener('keyup', stopEvent, true);
      window.addEventListener('keypress', stopEvent, true);

      document.addEventListener('keydown', stopEvent, true);
      document.addEventListener('keyup', stopEvent, true);
      document.addEventListener('keypress', stopEvent, true);
    }

    // Run the function to override events
    overrideKeyboardEvents();

})();