Prevent Slash Opening QuickFind

When the / key is received outside a text entry field, discard it

  1. // ==UserScript==
  2. // @name Prevent Slash Opening QuickFind
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @description When the / key is received outside a text entry field, discard it
  6. // @include *
  7. // @version 0.9.2
  8. // @grant none
  9. // @copyright Copyright 2015 Jefferson Scher
  10. // @license BSD 3-clause
  11. // ==/UserScript==
  12.  
  13. function PSOQ_KeyCheck(key){
  14. if (key.target.nodeName == "INPUT" || key.target.nodeName == "TEXTAREA" || key.target.nodeName == "SELECT") return;
  15. if (key.target.hasAttribute("contenteditable") && key.target.getAttribute("contenteditable") == "true") return;
  16. if (key.ctrlKey || key.shiftKey || key.altKey || key.metaKey) return;
  17. // codes for / and ' key on my Windows 7, your keyCode may vary?
  18. if (key.which == 191 || key.which == 222){
  19. key.stopPropagation();
  20. key.preventDefault();
  21. return false;
  22. }
  23. }
  24. document.onkeydown = PSOQ_KeyCheck;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址