-1

There has to be a way to simply disable the default functionality of Alt + F4 (shutting down Windows or closing an application) using regedit, right? Without also potentially disabling the ability to shut the computer down at all? I can't find anything that's up-to-date about this. I use Alt+F# hotkeys for shortcuts in Lazy Nezumi, and I'd like to be able to use Alt+F4 for a shortcut, or if that's not an option, not have the application try to close if I accidentally hit Alt+F4.

I don't want to use AutoHotkey or write a script that has to constantly run in the background.

I've looked at these links, and I can't find anything usable here. This:

4
  • 1
    I have a HyperX keyboard which has a "gaming mode" that can be configured to disable a bunch of game breaking hotkeys like "Alt - F4" and the Windows key.
    – Mokubai
    May 8, 2023 at 15:16
  • If you don't need F4, remove the key. If you just want to prevent accidentally shutting Windows, put foam plastic under the F4 key so it requires more pressure. No extra software needed. N.B. While one could remap the F4 key, that applies to all applications, so one could not shut an app with Alt-F4. May 8, 2023 at 16:12
  • @DrMoishePippik, OP wrote "or closing an application" so that'd be desired for him. May 8, 2023 at 16:16
  • 1
    @YisroelTech, thanks for pointing that out. He could use epoxy under the key, too. ;-) (Actually, that is the technique used to prevent some PC's from using USB -- filling the port.) May 8, 2023 at 16:29

5 Answers 5

2

You should be able to use any Keyboard Remapper to do that.

(TBH, they are obviously simpler than AutoHotkey intercepting the key press, but they'd still be a utility running on the system, so not sure if it's good enough for you.)

I like the Keyboard Manager that comes as part of Microsoft PowerToys (which packs a buncha other neat little optional utilities):

  1. Go to Microsoft PowerToys Settings > Keyboard Manager
  2. Choose Remap a shortcut
  3. Select Alt+F4 from Physical Shortcut:, and select Disable for Mapped to:

enter image description here

0
1

I am not sure if there is such an option.

If something is stuck and and Start, Shutdown is not available, or the screen does not show up, then Alt F4 is an orderly shut down whereas the power button forces a shutdown regardless of consequences.

I strongly suggest you leave Alt F4 as is.

2
  • 1
    Ctrl+Alt+Delete is usually better for that May 8, 2023 at 15:21
  • Is there not a way to simply map the shutdown hotkey to a different Alt+F? hotkey? May 8, 2023 at 16:39
1

If you wish to change the default action of Alt+F4 from Shutdown to another, do this :

  • Run regedit

  • Go to the registry key HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Explorer

  • Right-click some blank space and select New -> DWORD (32-bit) Value

  • Name the item PowerButtonAction and give it one of the following values:

    • 1 = Sign out
    • 2 = Shut down
    • 4 = Restart
    • 10 = Sleep
    • 40 = Hibernate
    • 100 = Switch user
  • Close the Registry Editor and reboot.

Reference : How to Change Default Setting for Alt+F4 Shut Down Windows Dialog.


To set AutoHotKey to "steal" the key combination from Windows and send it to the application, you may use this script:

!F4::SendPlay, !{F4}

However, I don't have an application that reacts to Alt+F4, but I did test that it doesn't terminate applications any more.

9
  • I should have clarified further - I actually want to use Alt+F4 for a hotkey in another application, but the action of Windows trying to close the application and shut down the system is getting in my way. If I could remap the hotkey in Windows to something like Alt+F12, that'd be acceptable. I don't really want to remap the Alt+F4 to a variant of shutdown, like signing out. May 8, 2023 at 16:39
  • 2
    In that case using AHK is your best bet by far, no idea why you don't want to use it, but including a reasoning in the question would be welcome.
    – Destroy666
    May 8, 2023 at 16:47
  • I added an AHK script that might do something useful, but I can't test it.
    – harrymc
    May 8, 2023 at 16:56
  • @Destroy666 .. have you considered the load of having auto hot key running and evaluating all that it does? I myself am a minimalist and don't want more background tasks than I need.. especially ones evaluating every key stroke and window creation via hook and or pooling. That's just me but that is indeed a reason. Total respect for you.. just giving a different point of view. May 8, 2023 at 17:12
  • 1
    @SatoshiNakamoto: See AutoHotkey #IfWinActive.
    – harrymc
    Sep 6, 2023 at 7:14
0

There are some great answers here.. but if you literally want to disable the ALT-F4 key from functioning without a hack, you can do the same thing I do for disabling my caps lock key.

It involves a simple registry edit to change the way Windows will interpret (and in this case ignore) the keys as they are coming in.


Windows Registry Editor Version 5.00

; Disable Left & Right ALT keys and F4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,00,00,3e,00,00,00,38,00,00,00,38,e0,00,00,00,00

Save this text as a .reg file and run it followed by a reboot.
Problem solved.

Also.. source is here .. not that anyone couldn't have done this but I didn't need to lookup the scan key codes.. I just used the material I referenced.

0

disabling this functionality is CLEARLY, if you think, done bc you NEED the ALT+F4 to something else.. like hmmm well maybe you need it as part of the normal hotkeys for nvidia shadowplay, photo functions etc, which is CTRL+ALT+F1,2,3,4,5,6,7,8,9,10,11,12.... if you use this a LOT you would want to just ALT+F key it instead.

its also valid to stated anything worth alt f4 is worth checking the process in ctrl alt del. i seen alt f4 used more for trolling unknowingly then for developing (as there is so many better ways to handle such situations honestly)

You must log in to answer this question.

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