View Single Post
  #3  
Old April 27th 20, 04:25 AM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 744
Default How to disable a keyboards shutdown and sleep keys ?

On Sun, 26 Apr 2020 15:18:44 +0200, R.Wieser wrote:
Hello all,

I've had to get myself a new keyboard, and it got two keys I could do well
without: One that instantly turns my computer off and another which, also
instantly, makes it sleep.

I've been googeling for solutions, but the ones I could find just mitigate
the effects. Like I have disabled the "sleep" mode of my 'puter (blocking
the effect of the "sleep" key) and changed the "power button" setting from
"shut down" to "Ask me what to do" - which /ofcourse/ now also happens when
I push the on/off button on the desktop machine itself. :-(

I've been looking into the "Scancode map" (replacing the "keystrokes" with
something else), but have not been successfull in that regard.

tl;dr: does anyone have an idea how to (programmatically!*) disable the
'power' and 'sleep' keyboard keys ?

*if all else fails I guess I could physically remove those keys, but want to
see if it can be done less destructive.

Regards,
Rudy Wieser


The keyboars's power management keys aren't disableable or mappable by user
code, because those keys are handled by the kernel before they're being
mapped by the built in keyboard mapper, then passed to applications. The
flow i.e.:

Physical key - Driver stack - Kernel(Handler(Mapper)) - User

One way to disable the Power and Sleep keys, is to reconfigure the system's
global power scheme using WriteGlobalPwrPolicy() function, and change the
PowerButtonAc, PowerButtonDc, SleepButtonAc, and SleepButtonDc fields to a
value which represent a do-nothing.

The alternative way is to create a keyboard filter driver which changes
power management key scan codes before they're handled by the kernel.
Ads