Advertisement
Guest User

Untitled

a guest
Oct 11th, 2023
1,261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Example Userscript Keypress
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Run userscript on Shift keypress
  6. // @author       dsasmblr
  7. // @match        https://*.reddit.com/*
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
  9. // @grant        none
  10. // @run-at       document-idle
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.     'use strict';
  15.  
  16.     window.doTheThing = () => {
  17.         alert('I did it!');
  18.     }
  19.  
  20.     document.querySelector('body').addEventListener("keydown", (event) => {
  21.         if (event.key === "Shift") {
  22.             window.doTheThing();
  23.         }
  24.     });
  25. })();
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement