3

I sometimes hate to move the mouse, just to hit the close button or to press ALT+F4 to terminate a running software/program or an active window. Honestly, I feel more comfortable to simply hit ESC key, (which applies to other programs). Can I make this works to all running software?

6
  • 6
    Vim users ain't gonna like you...
    – lornix
    May 30, 2014 at 6:57
  • 2
    I can imagine there are many instances where it'd be awkward.
    – Holloway
    May 30, 2014 at 8:01
  • 3
    There are many programs where ESC is expected to bring up some sort of menu, from where you can then exit. Especially games or simulations.
    – David S.
    May 30, 2014 at 12:20
  • May be helpful superuser.com/questions/488827/autohotkey-winclose-with-ctrlw
    – Dave
    May 30, 2014 at 13:25
  • What are you going to use to replace ESC's original meanings?
    – Jon Hanna
    May 30, 2014 at 13:53

2 Answers 2

5

It really depends on the programs you are using. So, an option which might work is Auto Hot Key.

However, it will have possible negative results. For example, only some programs will close with certain commands, so if you mapped ALT F4 to ESC but a program only recognises ALT F4 as the shutdown, then it won't work!

So, you could then map several commands to AutoHotKey, where hitting ESC sends ESC, then Ctrl+F4 then ALT+F4 then CTRL+W and then CTRL+Q etc (no idea how long this list would need to be). Again, the implications of this may not be desirable.

Another issue about mapping the ESC is what happens when you don't want to exit the program but still want to send ESC?

Personally, I would just learn which combination to press. However, you may be better to create a new combination, such as ALT+ESC which sends all the of the possible close commands (listed above as a guide).

13
  • 1
    I would assume you mean ALT F4? or is it CTRL F4?
    – stack
    May 30, 2014 at 7:09
  • So if Alt+F4 closes the Word doc which you have open, then is the script going to be smart enough to not proceed with Ctrl+W right afterwards? If Windows focuses on a web browser which you have open in the background after closing the Word doc then it is going to close at least one tab. For every solution added to solve this non-problem you need to recalculate your new problems as problems^solutions
    – MonkeyZeus
    May 30, 2014 at 13:09
  • Surely there has to be a way for a program to intercept "ESC" and send a SIGTERM or SIGQUIT to the active application... (or WM_CLOSE or whatever it is in windows)
    – Cruncher
    May 30, 2014 at 13:14
  • I'm not saying there is or isn't really.. But the OP mentions ALT F4 only, I've just explained why that may not work, and provided extra suggestions/situations and thoughts which, based upon their future research, may result in something that suffices @Cruncher .. Who knows, there may be already be an app that exists? :)
    – Dave
    May 30, 2014 at 13:15
  • 1
    @DaveRook Let me back up a step here, I like your suggestion and think that it can be tweaked and applicable in certain ways. The purpose of my comment was to educate OP as to why this is an XY problem and how a solution will actually create new problems. Kind of like how a person with minor but manageable back pain goes in for surgery and relieves their back problems but a week later a blood clot from the surgery is jarred and causes a debilitating stroke.
    – MonkeyZeus
    May 30, 2014 at 13:20
2

If you're trying to do this in Windows, download and install AutoHotkey.
Open Notepad and copy+paste this line of code and save it as .AHK file and double click it.

Esc::Send !{f4}

If you want to, you can compile the script, which creates an executable EXE file that you can carry with you to use on any Windows machine where you want Esc mapped to Alt+F4 key combination.

ESC Remap

You must log in to answer this question.

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