30

I just accidentally pressed Ctrl+Shift+W again and lost some work. I like using CTRL+W for individual windows, but I never want to close everything. Is there a way to disable this on Chrome?

  • 3
    It's a shame hotkeys still cannot be disabled/altered. I would like to use Ctrl + Shift + Q in Cloud9 IDE, but that closes my Chrome :( – Richard de Wit Jan 20 '15 at 15:58
  • 2
    This is not a Windows-specific issue. It is a general browser issue and these browsers (Chrome and Firefox) both use these same hot-key combos in Ubuntu linux as well. AHK doesn't support other OSes, but I wonder if there are solutions that could work for those OS as well. – music2myear Jan 5 '17 at 18:27
  • For MacOS the chrome installation has an option "Warn before quitting" in the Chrome menu. It's saved me many times over. – Rebecca Dessonville Jan 5 '17 at 22:40
  • Here you can find more options even without using AutoHotkey. I really like this approach. – Michael Berdyshev Feb 6 '18 at 18:07
  • This is a good question! I often use the middle of a pinky to press ctrl and another finger to press w to close individual tabs. It is so easy for the pinky to sometimes also press the large shift key right above ctrl. I don't want to have to use autohotkey though to remedy this. – user3015682 May 26 '19 at 3:19
8

You can use AutoHotkey to intercept the keyboard shortcut:

SetTitleMatchMode, Regex

#IfWinActive, (- Google Chrome)$
    ^+w::
        ;do nothing
        return

#IfWinActive
| improve this answer | |
  • 1
    This example did not work for me with AutoHotKey v1.1.09.02. After some tweaking I got this working: #IfWinActive, ahk_class Chrome_WidgetWin_1 ^w::Return #IfWinActive – Steven Devijver Jan 19 '13 at 21:45
20

The answer by iglvzx doesn't work for newer versions of AutoHotKey (AHK). Here is how you can do it with newer AHK versions:

SetTitleMatchMode, Regex

#IfWinActive, ahk_class Chrome_WidgetWin_1
    ^+w::
        ;do nothing
        return
    ^+q::
        ;do nothing
        return

#IfWinActive

This also prevents Ctrl+Shift+Q from quitting all of Chrome.

| improve this answer | |
  • (to send ctrl W just remove the +) – JinSnow Nov 5 '17 at 22:03
  • This should be the default answer. This also works with Firefox Quantum if you change the ahk_class to MozillaWindowClass – ifconfig Nov 19 '17 at 22:45
  • Ctrl+Shift+Q is disabled now in one of the latest chrome updates, so it is no longer necessary to block – pfg Nov 3 '18 at 21:03
2

Complete version of this script. Works on new AHK versions.

  • Works with any input language (assigned to key code, not key as letter)
  • Only one running instance (SingleInstance force)
  • Doesn't recording history of pressed keys (KeyHistory 0)
  • Prevents from Ctrl+Shift+W and Ctrl+Shift+Q in Chrome
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force;
#KeyHistory 0 ;
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

SetTitleMatchMode, Regex
#IfWinActive, ahk_class Chrome_WidgetWin_1
    ^+SC011::
        ;do nothing
        return
    ^+SC010::
        ;do nothing
        return
#IfWinActive
| improve this answer | |
  • please help me format this code! – robertono Apr 14 '16 at 12:28
  • 1
    You had missed the closing </pre> tag – Burgi Apr 14 '16 at 13:41
  • The chrome keybinding is language dependent for at least my version (61.0.3163.100) of chrome, so it doesn't work better to use the scancode. – William Cushing Oct 4 '17 at 20:04
0

This binds ctrl-w to perform a kind of select-word in every application, and disables closing chrome using ctrl-shift-w and ctrl-shift-q. Tested on english and french language input methods for windows 10.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
#SingleInstance FORCE
#KeyHistory 0
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^w:: ; select word
    Send, ^{right}^{left}^+{right}
    return

SetTitleMatchMode, Regex
#IfWinActive, ahk_class Chrome_WidgetWin_1
    ^+w::return ; make ctrl-shift-w do nothing
    ^+q::return ; make ctrl-shift-q do nothing
#IfWinActive
| improve this answer | |
0

Here is the autohotkey code to disable ctrl+w and ctrl+q for the tab named test1 and test2 (test1 is the title that appears on your tab. You can use also use autohotkey spy to figure out more stuff)

SetTitleMatchMode, Regex

#If WinActive("test1 ahk_class Chrome_WidgetWin_1") || WinActive("test2 ahk_class Chrome_WidgetWin_1") 
        ^w::
        ^q::
            return  ; do nothing

#IfWinActive

credit to Raj and this guy

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.