您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Stop websites from hijacking Firefox quick search key "/", and Escape key
// ==UserScript== // @name Disable single key keyboard shortcuts // @description Stop websites from hijacking Firefox quick search key "/", and Escape key // // @run-at document-start // @include * // @grant none // @inject-into auto // @version 2019.12.31.1600 // @namespace https://greasyfork.org/users/30 // ==/UserScript== /* jshint esversion: 6 */ //https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key const keyValues = new Set(['/','Escape']); // Check on https://keycode.info/ const preventKey = function(e){ if (keyValues.has(e.key)){ e.stopImmediatePropagation(); } //console.log('Event: type: %s, key: %s, has: %s', e.type, e.key, keyValues.has(e.key)); }; // Slash search on https://github.com/ document.addEventListener('keydown', preventKey, {passive: false, capture: true}); // Slash search on https://forum.manjaro.org/ // `capture` for Slash search on https://phabricator.services.mozilla.com/ document.addEventListener('keypress', preventKey, {passive: false, capture: true}); // I need to find test case //document.addEventListener('keyup', preventKey);