How to disable keyboard shortcut CTRL+W?
Hello,
I am trying to disable keyboard shortcut CTRL+W, but there does not seem to be any options or addons for such issue. Is it possible to disable such keyboard shortcut? Actually, I am using CTRL+W into a gaming cloud which is accessible in browser. Thanks for your attention!
Best regards, Winserity
Выбранное решение
You can possibly run code in the Browser Console to disable this shortcut, but that only works for the current window and you need to remember to run the code. The Browser Console has a command stack and remembers commands you have used, so you may only need a cursor UP to recall this code and press ENTER if you have used this.
- "3-bar" menu button or Tools -> Web Developer
- https://developer.mozilla.org/en-US/Tools/Browser_Console
I use this code to disable Ctrl+Q to avoid accidentally closing Firefox (Q is next to W). You can easily add more key IDs.
javascript:/*ACCESSKEY*/(function(){var wd = Services.wm.getMostRecentWindow("navigator:browser").window.document;function $(e){return(wd.getElementById(e))}function $(e){var N=$(e);if(N){N.removeAttribute("key"); N.removeAttribute("command");console.log(N)}return($(e))}$("key_quitApplication");$("key_privatebrowsing");$("key_close");})()
You can possibly use a bookmarklet (bookmark with this code in the location field) to get this JavaScript code in a prompt and copy it to the clipboard.
javascript:/*ACCESSKEY*/void(prompt('<accesskeys>',atob('amF2YXNjcmlwdDovKkFDQ0VTU0tFWSovKGZ1bmN0aW9uKCl7CnZhciB3ZCA9IFNlcnZpY2VzLndtLmdldE1vc3RSZWNlbnRXaW5kb3coIm5hdmlnYXRvcjpicm93c2VyIikud2luZG93LmRvY3VtZW50OwpmdW5jdGlvbiAkKGUpe3JldHVybih3ZC5nZXRFbGVtZW50QnlJZChlKSl9CmZ1bmN0aW9uICQkKGUpe3ZhciBOPSQoZSk7aWYoTil7Ti5yZW1vdmVBdHRyaWJ1dGUoImtleSIpOyBOLnJlbW92ZUF0dHJpYnV0ZSgiY29tbWFuZCIpO2NvbnNvbGUubG9nKE4pfXJldHVybigkKGUpKX0KJCQoImtleV9xdWl0QXBwbGljYXRpb24iKTsKJCQoImtleV9wcml2YXRlYnJvd3NpbmciKTsKJCQoImtleV9jbG9zZSIpOwp9KSgp')));
Прочитайте этот ответ в контексте 👍 1
Все ответы (4)
You can try something like this with code in the autoconfig.cfg file.
See also:
You need to remove this key binding for close tab (Ctrl+W):
<key id="key_close" data-l10n-id="close-shortcut" command="cmd_close" modifiers="accel" reserved="true" key="W"/>
I'm glad that there is at least a solution. However, I have limited privileges (non-admin Windows user) to apply this solution. That would be great if such option could be integrated in the preferences tab in next update for Mozilla Firefox.
Thank you for your volunteer assistance!
Выбранное решение
You can possibly run code in the Browser Console to disable this shortcut, but that only works for the current window and you need to remember to run the code. The Browser Console has a command stack and remembers commands you have used, so you may only need a cursor UP to recall this code and press ENTER if you have used this.
- "3-bar" menu button or Tools -> Web Developer
- https://developer.mozilla.org/en-US/Tools/Browser_Console
I use this code to disable Ctrl+Q to avoid accidentally closing Firefox (Q is next to W). You can easily add more key IDs.
javascript:/*ACCESSKEY*/(function(){var wd = Services.wm.getMostRecentWindow("navigator:browser").window.document;function $(e){return(wd.getElementById(e))}function $(e){var N=$(e);if(N){N.removeAttribute("key"); N.removeAttribute("command");console.log(N)}return($(e))}$("key_quitApplication");$("key_privatebrowsing");$("key_close");})()
You can possibly use a bookmarklet (bookmark with this code in the location field) to get this JavaScript code in a prompt and copy it to the clipboard.
javascript:/*ACCESSKEY*/void(prompt('<accesskeys>',atob('amF2YXNjcmlwdDovKkFDQ0VTU0tFWSovKGZ1bmN0aW9uKCl7CnZhciB3ZCA9IFNlcnZpY2VzLndtLmdldE1vc3RSZWNlbnRXaW5kb3coIm5hdmlnYXRvcjpicm93c2VyIikud2luZG93LmRvY3VtZW50OwpmdW5jdGlvbiAkKGUpe3JldHVybih3ZC5nZXRFbGVtZW50QnlJZChlKSl9CmZ1bmN0aW9uICQkKGUpe3ZhciBOPSQoZSk7aWYoTil7Ti5yZW1vdmVBdHRyaWJ1dGUoImtleSIpOyBOLnJlbW92ZUF0dHJpYnV0ZSgiY29tbWFuZCIpO2NvbnNvbGUubG9nKE4pfXJldHVybigkKGUpKX0KJCQoImtleV9xdWl0QXBwbGljYXRpb24iKTsKJCQoImtleV9wcml2YXRlYnJvd3NpbmciKTsKJCQoImtleV9jbG9zZSIpOwp9KSgp')));
cor-el said
You can possibly run code in the Browser Console to disable this shortcut, but that only works for the current window and you need to remember to run the code. The Browser Console has a command stack and remembers commands you have used, so you may only need a cursor UP to recall this code and press ENTER if you have used this.I use this code to disable Ctrl+Q to avoid accidentally closing Firefox (Q is next to W). You can easily add more key IDs.
- "3-bar" menu button or Tools -> Web Developer
- https://developer.mozilla.org/en-US/Tools/Browser_Console
javascript:/*ACCESSKEY*/(function(){var wd = Services.wm.getMostRecentWindow("navigator:browser").window.document;function $(e){return(wd.getElementById(e))}function $(e){var N=$(e);if(N){N.removeAttribute("key"); N.removeAttribute("command");console.log(N)}return($(e))}$("key_quitApplication");$("key_privatebrowsing");$("key_close");})()
You can possibly use a bookmarklet (bookmark with this code in the location field) to get this JavaScript code in a prompt and copy it to the clipboard.
javascript:/*ACCESSKEY*/void(prompt('<accesskeys>',atob('amF2YXNjcmlwdDovKkFDQ0VTU0tFWSovKGZ1bmN0aW9uKCl7CnZhciB3ZCA9IFNlcnZpY2VzLndtLmdldE1vc3RSZWNlbnRXaW5kb3coIm5hdmlnYXRvcjpicm93c2VyIikud2luZG93LmRvY3VtZW50OwpmdW5jdGlvbiAkKGUpe3JldHVybih3ZC5nZXRFbGVtZW50QnlJZChlKSl9CmZ1bmN0aW9uICQkKGUpe3ZhciBOPSQoZSk7aWYoTil7Ti5yZW1vdmVBdHRyaWJ1dGUoImtleSIpOyBOLnJlbW92ZUF0dHJpYnV0ZSgiY29tbWFuZCIpO2NvbnNvbGUubG9nKE4pfXJldHVybigkKGUpKX0KJCQoImtleV9xdWl0QXBwbGljYXRpb24iKTsKJCQoImtleV9wcml2YXRlYnJvd3NpbmciKTsKJCQoImtleV9jbG9zZSIpOwp9KSgp')));
Thank you for such a great solution! You are genius :) Google provides so many threads regarding this issue, but none of them helped me as much as you. I have tried that javascript code, but it does not work or I don't know how to apply it. However, I have accessed the Browser Toolbox and deleted following node:
<key id="key_close" data-l10n-id="close-shortcut" command="cmd_close" modifiers="accel" reserved="true" key="W"/>
By deleting that node, I can use keyboard shortcut CTRL+W without to be closed browser tab. By the way, the correct link to documentation of Browser Toolbox is https://developer.mozilla.org/en-US/docs/Tools/Browser_Toolbox