Disable reddit keyboard shortcuts

Disables keyboard shortcuts on reddit

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 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         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();

})();