35

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?

5
  • 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 :( Jan 20, 2015 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. Jan 5, 2017 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. Jan 5, 2017 at 22:40
  • Here you can find more options even without using AutoHotkey. I really like this approach. Feb 6, 2018 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. May 26, 2019 at 3:19

7 Answers 7

10

You can use AutoHotkey to intercept the keyboard shortcut:

SetTitleMatchMode, Regex

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

#IfWinActive
1
  • 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 Jan 19, 2013 at 21:45
23

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.

3
  • (to send ctrl W just remove the +)
    – JinSnow
    Nov 5, 2017 at 22:03
  • 1
    This should be the default answer. This also works with Firefox Quantum if you change the ahk_class to MozillaWindowClass
    – ifconfig
    Nov 19, 2017 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, 2018 at 21:03
3

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
3
  • please help me format this code!
    – robertono
    Apr 14, 2016 at 12:28
  • 1
    You had missed the closing </pre> tag
    – Burgi
    Apr 14, 2016 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. Oct 4, 2017 at 20:04
2
  1. Install the Chrome extension "Disable keyboard shortcuts", by Benjamin Barenblat. (You may also view the source code, if you wish.)
  2. Visit the URL: chrome://extensions/shortcuts
  3. If you're on Windows, assign Control+Shift+W to do nothing in Chrome. (If you're on Mac OS, assign Cmd+Shift+W instead.)
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
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

0

it think this might work:

1- Press WIN + R to open Run dialog (alternatively right click Start, select Run), type control /name Microsoft.Language, press OK:

2- This opens Control Panel > All Control Panel items > Language. Select Advanced settings:

3- Select Change language bar hot keys:

4- In Advanced Key Settings tab, select Change Key Sequence:

5- Change key sequence, click OK to save settings:

6- Notice that Switch Input Language and Switch Keyboard Layout can't have the same sequence. To avoid using CTRL + SHIFT you can for instance set Switch Input Language to Grave Accent and Switch Keyboard Layout to Left Alt + SHIFT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .