Trapping the 'windows' key?

Started by
5 comments, last by Spodi 14 years, 7 months ago
Does anyone know how to trap the Windows key (key with the windows logo on it)? I have a fullscreen game that is getting interrupted whenever someone bumps that key.
Advertisement
Get used to it.

Learn to deal with cases like that. The chances of someone bumping that key are infrequent unless you've got a poor keyboard layout. Such as forcing someone to use both ctrl and alt.

There's no point in trapping my Windows key, just as there's no point in trying to trap ctrl+alt+delete. Just learn to handle the case. If this is a single player game put it into a paused state when you lose focus, or if it's a multiplayer game then deal with it in an alternative way. Lost devices are a natural occurrence and can happen for more reasons than just someone bumping the windows key.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

The windows key can be trapped using a low level Keyboard hook in windows.

See:

SetWindowsHookEx
LowLevelKeyboardProc
KBDLLHOOKSTRUCT

And the MSDN article on disabling shortcut keys for games

Cheers!
Yeah. I HATE games that lock things like alt-tab or the windows key. Even ones that don't run in windowed mode to start with can be anoying. What if i need to us external IM? look at a hint guide? manage a VOIP app?

If they are really annoyed at the functionality of the windows key, they should either get a gaming keyboard (like the saitek Cyborg) that disables the key when in gaming mode, or they should learn not to hit the key (it isn't that hard).
Quote:Original post by KulSeran
Yeah. I HATE games that lock things like alt-tab or the windows key. Even ones that don't run in windowed mode to start with can be anoying. What if i need to us external IM? look at a hint guide? manage a VOIP app?

If they are really annoyed at the functionality of the windows key, they should either get a gaming keyboard (like the saitek Cyborg) that disables the key when in gaming mode, or they should learn not to hit the key (it isn't that hard).


I don't plan on locking alt+tab, or ctrl+alt+delete. Just the windows key, and only during fullscreen mode.

I also need to lock out 'sticky keys' notification, which comes up if you hit shift 5 times in a row.

The problem is we need three action buttons on the keyboard, for the left hand, because the right hand is using the arrow keys. Those action buttons are shift, alt, and spacebar. So often the windows key is getting pressed, and the shift key is getting pressed 5 times in a row.

You guys can argue design with me all you want, I'm just the programmer, and I've already argued my case to the designers. If they want annoying key layouts, I have no choice but to implement it.

Thanks for the feedback and help though. :)
I just checked the technical requirements list for Games For Windows (although I have a list from 10 years ago, but I doubt it changed much in regards to this):

Quote:2.6 Games must not attempt to disable standard task switching. Games must not disable the ALT+TAB keyboard shortcut. Games are allowed to disable accessibility keyboard shortcuts, as described in Disabling Shortcut Keys in Games.


So yeah, Microsoft seems to consider OK to let games disable the Windows and accessibility keys (both are described in that document, which was linked here earlier -- and to be fair it's more likely to press it by accident than Alt+Key and most of the time you won't want to call the Start menu like that anyways).
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
Well, if you have people complain about it being gone (though I have NEVER heard of someone being happy to have that Windows key there when playing games...), just have it on by default but add an option to have it behave as normal. Everyone is happy.

The Windows key is, in my opinion, an exception. I wish it was actually easier for it to be disabled by fullscreen programs so more people would do it, or easier to reassign it to another key (or key combination, like Alt+Win). Stuff like Alt+Tab is only a problem if those are both commonly pressed buttons (which most all Windows games have learned to avoid doing), and Ctrl+Alt+Del is rarely a combo you will be pressing all at once. But the Windows key is right there in the open, a single key stroke, and quite disastrous in this world where too many games still fail to properly recover from losing focus.
NetGore - Open source multiplayer RPG engine

This topic is closed to new replies.

Advertisement