A Simple Trick: Disabling a Specific Key

Most of the time, I learn something new because I have a problem to solve. I’ll tolerate some annoyances as long as they’re minor but if they go on for a while or start becoming worse, I go looking for a solution.

I’ve been playing Fallout 4 a bit lately. I know I’m not the most dextrous gamer around. I am, however, far more comfortable with mouse and keyboard than I am with any controller. So when I get into a combat situation and I start flailing around on the keyboard trying to shoot the super mutants, I have found myself hitting the Windows key, which pauses the game and drops me back to the desktop.

Supermutants are simple. Here, Strong tells us its entire character arc.
Super mutants are simple. Here, Strong tells us its entire character arc.

The first few times I just groaned, alt-tabbed back to the game, hit ESC and carried on. But it kept happening. I knew there must be a way to just turn off the Windows key entirely, at least while I was playing. Trouble is, I use that key regularly when I’m not playing. What about a more elegant solution?

Enter AutoHotkey (AHK). It’s a scripting program that runs in the background, waits for keyboard input, and then uses that to trigger actions. I use it as a text expander already: when I type “sphn”, for instance, AHK will expand that to my phone number. Super handy!

And as it turns out, there’s a way to get to have specific key combinations tied to specific programs. So I could have it just ignore the Windows key, but only when Fallout 4 had the focus.

I went looking, and found that I only had to add the following lines to an AHK script I’m already using:

#IfWinActive, ahk_class Fallout4
~LWin Up:: return

The first line tells AHK to only run the next line if the window that’s named “Fallout4” is the active window. And the next line is what I want to happen: do nothing at all when the Windows key is released.

Now, no matter what flailing I do when feral ghouls attack, I won’t take myself out of the game by tapping the wrong key, letting me stay in the moment. Much better!

There’s probably plenty more uses for this trick, like re-mapping all the controls (or just the annoying ones) in a stubborn program. Thankfully, AHK is well-documented. For now, though, I’m happy I went looking for the answer to this question.