How can I change the default shortcut in Windows for closing programs?

25

10

I like the close program keyboard shortcut in Mac OS X which is + Q. Nice and convenient for hand placement. In Windows however, the equivalent shortcut is Alt + F4, a little awkward.

Is there a way to change the default keyboard shortcut to Alt + Q or Ctrl + Q? I'm using Windows 7.

v15

Posted 2011-02-25T20:15:47.647

Reputation: 1 805

4Alt+F4 closes windows, not programs. You can probably cook something up in AutoHotkey, but since Windows program commands don't always show up in menus, you might lose some commands that are executed using Ctrl/Alt+Q – Daniel Beck – 2011-02-25T20:19:11.077

1Alt+F4 will close a program for me. I just checked the 'Quit' command in Word and it's Alt+F4. Perhaps a registry edit? Not sure where to look though. – v15 – 2011-02-25T20:20:25.130

4If programs close when their last window is closed, then yes, Alt+F4 closes programs if you use it to close their last open window. But it's not generally a "quit program" shortcut. There's no such thing as the Keyboard Shortcuts preferences pane in OS X on Windows. Your only hope is input redirection (like I suggested) or a third-party tool. – Daniel Beck – 2011-02-25T20:40:07.823

1In my Windows, ALT+F4 also closes the whole program, even if it has more than one document/window opened. STRG+F4, however, closes a single document window. This is applicable to most, if not any, programs I use on Windows. – Martin – 2011-04-26T14:07:20.347

Answers

31

Get AutoHotKey. Open Notepad and paste the following:

^q::Send !{F4}
return

Save it as an .ahk file, run it and try it out. If it works, stick it in your startup folder and you are good to go. The above code simply maps Ctrl + Q to Alt + F4.

If you want it to be Alt + Q, then replace the ^ with a !

If you can't get AutoHotKey, I've compiled the above script for you and uploaded it here:

http://dl.dropbox.com/u/26194020/CtrlQ.exe

Download and enjoy.

By the way - you do know that Ctrl + W closes a window in any application already, right?

yeedl

Posted 2011-02-25T20:15:47.647

Reputation: 1 056

I took me a while before I realized you actually have to double click the resulting file. So here's my FYI, don't look in AutoHotKey for a way to run it and just run the file. Totally works btw. – Herman – 2020-01-28T09:32:00.843

7Ctrl+W is merely a common shortcut that has been adopted by many programs. It is not defined by Windows and doesn't work in all, or even most, applications. – Hugh Allen – 2011-04-28T12:25:12.677

Share and enjoy. – Mateen Ulhaq – 2011-05-02T00:11:30.120

2

To change Windows to suit a Mac user, see this article : Key Remapping in Windows.
It contains an Autohotkey script that maps many Windows keys to their Mac equivalents.

To build a new keyboard layout, see The Microsoft Keyboard Layout Creator, which lets you manipulate all keys and their combinations.

As the original article has disappeared from the Web, I copy below the Autohotkey script:

;Autohotkey script
;John Walker, 2010-11-25
;http://www.inertreactants.com
;Feel free to reuse, edit and redistribute
;Key remaps for Apple users using boot camp
;(with an Apple notebook or Keyboard)

;following section remaps alt-delete keys to mimic OSX
;command-delete deletes whole line
#BS::Send {LShift down}{Home}{LShift Up}{Del}

;alt-function-delete deletes next word
!Delete::Send {LShift down}{LCtrl down}{Right}{LShift Up}{Lctrl up}{Del}

;alt-delete deletes previous word
!BS::Send {LShift down}{LCtrl down}{Left}{LShift Up}{Lctrl up}{Del}

;following section mimics command-q and command-w
;behaviour to close windows
;note these had to be disabled below for the
;command to ctrl key remaps
#w::^F4
#q::!F4

;following section remaps alt-arrow and command-arrow
;keys to mimic OSX behaviour
#Up::Send {Lctrl down}{Home}{Lctrl up}
#Down::Send {Lctrl down}{End}{Lctrl up}
#Left::Send {Home}
#Right::Send {End}
!Up::Send {Home}
!Down::Send {End}
!Left::^Left
!Right::^Right

;following section remaps command key to control key
;affects all number and letter keys
;note that some keys, like winkey-l and winkey-d
;need to be remapped a differeny way
;otherwise autohotkey will not take over
#a::^a
#b::^b
#c::^c
#d::^d
#e::^e
;following won't remap using the normal method
#f::Send {LCtrl down}{f}{LCtrl up}
#g::^g
#h::^h
#i::^i
#j::^j
#k::^k
;#l::Send {LCtrl down}{l}{LCtrl up} ;disabled, I like winkey-L
#m::^m
#n::^n
#o::^o
#p::^p
;#q::^q ;disabled --remapped to alt-F4 instead
#r::^r
#s::^s
#t::^t
#u::^u
#v::^v
;#w::^w ;disabled --remapped to ctrl-F4 instead
#x::^x
#y::^y
#z::^z
#1::^1
#2::^2
#3::^3
#4::^4
#5::^5
#6::^6
#7::^7
#8::^8
#9::^9
#0::^0

harrymc

Posted 2011-02-25T20:15:47.647

Reputation: 306 093

Two out of three links are dead :( – Nathan Friend – 2019-04-29T11:55:54.553

@NathanFriend: I have replaced the links with equivalents, which still seem pertinent, and also copied here the Autohotkey script. – harrymc – 2019-04-29T17:57:11.483

Awesome, thanks @harrymc! :) – Nathan Friend – 2019-04-29T18:15:14.690

In this context, I'd like to also mention KbdEdit which is one of my favorite utilities.

– Ville – 2019-08-07T07:21:51.713