You hit the Windows key by accident mid-game and your fullscreen app drops straight to the desktop, or Caps Lock turns your password into shouting again. You can switch off any key in Windows 11 or Windows 10 with Microsoft PowerToys, a one-line AutoHotkey v2 script, or a registry mapping.
| Method | Best for | Needs to keep running? | Difficulty |
|---|---|---|---|
| PowerToys Keyboard Manager | Turning off a key with no code | Yes | Easy |
| AutoHotkey v2 script | Several keys, per-app rules, quick on/off | Yes | Easy to Medium |
| Registry Scancode Map | A permanent change for every user on the PC | No | Hard |
Fix #1: Disable the key with PowerToys Keyboard Manager
PowerToys Keyboard Manager is Microsoft’s free tool for remapping keys and shortcuts. If you’d rather click than script, start here.
- Install Microsoft PowerToys from the Microsoft Store. If the Store is blocked on your PC, Microsoft also supports installing it with WinGet or from GitHub.
- Open PowerToys Settings.
- Select Keyboard Manager in the sidebar.
- Turn on Enable Keyboard Manager.
- Select Remap a key.
- Select Add key remapping.
- In the left column (labeled Select or similar), pick the key you want to turn off.
- In the right column (labeled To send or similar), choose Disable (shown as Disabled in the new editor). The exact label for the no-action option can vary between PowerToys releases.
- Click OK.
Starting with PowerToys 0.100, new installations open the redesigned editor by default. That editor gained a Disabled action in PowerToys 0.99, so current releases include it; only older builds of the new editor lacked it. If you’re on an older build and can’t find it, turn off Use the new editor on the Keyboard Manager page to switch to the legacy editor, as described in Microsoft’s Keyboard Manager documentation. If neither editor offers it, use the AutoHotkey method in Fix #2.
Press the key. Nothing should happen.
The remap only works while PowerToys is running in the background with the Keyboard Manager module turned on. You don’t need to keep the PowerToys Settings window open, but if you exit PowerToys from the notification area or switch off Keyboard Manager, the key comes back.
If the key still works inside an app you’ve launched as administrator, Microsoft says remapping won’t apply to elevated windows unless you run PowerToys as administrator. That gives PowerToys admin rights for as long as it runs, so only turn it on if you actually need the remap inside elevated apps.
Fix #2: Disable keys with an AutoHotkey v2 script
AutoHotkey is a free scripting tool for Windows hotkeys and automation. It’s more flexible than PowerToys, and the script to kill a key is one line long.
Step 1: Install AutoHotkey v2
- Go to the AutoHotkey download page and download the current v2 release.
- Run the installer and accept the default options.
Write every script in v2 syntax. Plenty of older guides online use v1 commands, and those throw errors or silently fail in v2.
Step 2: Find the key’s name
AutoHotkey refers to keys by name. Check the list of supported key names for the one you want.
Common ones:
CapsLockfor Caps LockLWinandRWinfor the left and right Windows keysLAltandRAltfor the left and right Alt keysAppsKeyfor the Menu (context-menu) keyInsert,F1throughF24,Tab,Escape,Delete
Use these names. Don’t try to type the literal character.
Step 3: Create the script
- Right-click an empty spot in a folder you’ll keep, such as
Documents\Scripts. - Select New > AutoHotkey Script.
- Name it something clear, like
DisableKeys.ahk. - Right-click the file and choose Edit Script. If that option isn’t there, open the file in Notepad.
- Add one line per key you want to disable. To kill Caps Lock:
#Requires AutoHotkey v2.0
CapsLock::Return
Keep #Requires AutoHotkey v2.0 as the first line of every script. If v1 is also installed, it makes AutoHotkey run the file with v2 or show a clear error instead of misbehaving.
To kill both Windows keys:
#Requires AutoHotkey v2.0
LWin::Return
RWin::Return
The format is OriginKey::DestinationKey. Using Return as the destination tells AutoHotkey to do nothing, which is exactly what you want. The AutoHotkey v2 remapping docs use RWin::Return as their own example.
I’d skip disabling Alt entirely unless it’s actively wrecking something. It breaks menus, Alt + Tab, and plenty of app shortcuts. If you must, disable only LAlt and leave RAlt working.
- Save the file.
If you wrote the script in Notepad from scratch, set Save as type to All files and make sure the name ends in .ahk. A file saved as DisableKeys.ahk.txt won’t run.
Step 4: Run the script
- Open File Explorer and go to the folder with your script. The file should show the green AutoHotkey “H” icon.
- Double-click the file.
- Check the notification area for the green AutoHotkey icon. Click the up arrow next to the clock if it’s hidden.
Press the disabled key. If it does nothing, you’re done.
Step 5: Pause, reload, or stop the script
Right-click the AutoHotkey tray icon to control the script.
- Reload Script applies changes after you edit and save the file. Forgetting this step is a common reason a freshly edited script “doesn’t work.”
- Suspend Hotkeys turns your keys back on temporarily. The tray icon changes to show it’s suspended. Select it again to re-disable them.
- Exit stops the script completely.
Fix #3: Start the AutoHotkey script with Windows
The script stops when you restart your PC. A shortcut in your Startup folder relaunches it every time you sign in.
- Press
Windows + Rto open the Run dialog. - Type
shell:startupand press Enter. Your Startup folder opens in File Explorer.
- Open a second File Explorer window and go to the folder where your
.ahkfile lives. - Right-click the script and select Show more options > Create shortcut. On Windows 10, Create shortcut is right in the menu.
- Drag the new shortcut into the Startup folder.
Because the Startup folder only holds a shortcut, you can keep editing the original file in place. To undo it, delete the shortcut.
Fix #4: Disable a key only in one app or game
Maybe you want the Windows key dead in your game but working everywhere else. AutoHotkey v2 handles this with #HotIf.
- Find the app’s executable name. Open Task Manager, right-click the app, and select Go to details. The highlighted entry (like
ExampleGame.exe) is the name you want. The window title usually isn’t the same thing. - Edit your script and wrap the remaps like this:
#Requires AutoHotkey v2.0
#HotIf WinActive("ahk_exe ExampleGame.exe")
LWin::Return
RWin::Return
#HotIf
- Replace
ExampleGame.exewith the real executable name. - Save the file, then right-click the tray icon and select Reload Script.
The Windows keys should now do nothing while that app is in the foreground, as long as AutoHotkey can receive the app’s input. Switch to another window and they work normally. If the keys still work in the game, see the elevation and input notes under “When the fixes don’t work” below.
Microsoft documents a Target app field for PowerToys shortcut remaps, but its key-remap instructions don’t include a per-app option, so AutoHotkey is the more dependable tool for a per-game key block. Microsoft’s own Keyboard Manager documentation also lists, under Known Issues, that Keyboard Manager “shouldn’t be used when playing video games” because its interception of key presses “will impact the FPS.”
Fix #5: Disable a key permanently with the registry Scancode Map
This writes a machine-level mapping under HKLM that Windows loads at startup, so nothing has to keep running in the background. It normally affects every user who signs in to the PC, but existing mappings, keyboard utilities, Remote Desktop sessions, and firmware-level key handling can still change how a key behaves.
It’s also the hardest method to undo if you get it wrong. Your main safety net is the backup from step 2: after exporting it, confirm the .reg file is on your desktop and copy it somewhere safe before you change anything. A spare USB keyboard is a useful backup in case you disable the wrong key.
- Right-click Start and select Terminal (Admin). On Windows 10, choose Windows PowerShell (Admin).
- Back up the key by running
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" "$env:USERPROFILE\Desktop\KeyboardLayout-backup.reg". You should see “The operation completed successfully.” - Check for an existing mapping by running
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map". If it prints a value instead of an error saying the value can’t be found, this PC already has a key remap (often from a keyboard utility or an IT policy). The next command would overwrite it, so stop here and use PowerToys or AutoHotkey instead. - To disable Caps Lock, run
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map" /t REG_BINARY /d 00000000000000000200000000003A0000000000 /f.
- Restart your PC.
After the restart, Caps Lock should be disabled throughout normal Windows sessions. Behavior on the sign-in screen can vary by device and input path. The change is system-wide, and it’s reversible as long as you follow the check in step 3 or keep the backup from step 2. To bring the key back, run reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" /v "Scancode Map" /f in an admin terminal and restart again.
Step 3 confirmed there was no earlier mapping, so deleting the value returns the keyboard to its default layout. If you skipped that check and the backup file from step 2 contains a "Scancode Map" line, run reg import "$env:USERPROFILE\Desktop\KeyboardLayout-backup.reg" instead of deleting the value, then restart to restore the original mapping.
Don’t hand-edit other binary mappings unless you know the exact scan codes. A malformed value can disable the wrong key. And never map away Enter, Escape, or Ctrl without a way back in.
When the fixes don’t work
The Windows key still works in a game. One common cause is that the game runs as administrator while AutoHotkey or PowerToys doesn’t. Microsoft documents this limitation for PowerToys. AutoHotkey is commonly affected by the same Windows integrity-level restriction: a script that isn’t elevated usually can’t intercept keys meant for an elevated window, though results vary by app and how it reads input. The AutoHotkey FAQ on User Account Control covers the workarounds.
Running either tool as administrator gives it, and anything it launches, full admin rights, so do it only for a trusted script or setup and only while you need it. Also check whether you blocked LWin but you’re actually hitting RWin. A gaming keyboard with a Windows-key lock or Game Mode switch handles this in hardware, and its companion software can override your remaps.
You can’t block Ctrl+Alt+Delete. Windows protects that combination on purpose, and PowerToys lists it as reserved.
The Fn key won’t disable. Most laptops handle Fn in firmware before Windows ever sees it. AutoHotkey can catch the resulting F-key or media key, but not Fn itself. A programmable keyboard or the manufacturer’s own utility is usually the way to go, and some laptops also offer an Fn-lock or function-key setting in the BIOS/UEFI.
Nothing works in BIOS or over Remote Desktop. These tools only run inside Windows, and Remote Desktop processes some keys locally. Test your exact setup before relying on it.
Conclusion
For a single annoying key, Fix #1 (PowerToys) is the quickest to set up. AutoHotkey v2 (Fix #2) is my pick if you want per-game rules or a quick suspend from the tray. If a “disabled” key keeps working in one specific app, check admin privileges and your keyboard’s own software before reaching for the registry.