It indeed put the computer to sleep, but when I wake it using the computer’s power button, it goes back to sleep just after waking up. To prevent this I need to unplug my Model 100, wake the computer, then plug the keyboard again.
I conclude that somehow, the model 100 keeps sending the sleep signal instead of sending it only once.
any idea why it happens and how to solve it ?
Here’s what’s probably happening. The System Control USB HID protocol sends only a single “keycode” at a time. Basically, the report is either “off” or it has the value of whatever the latest key pressed is. The keyboard sends a report whenever a System Control key toggles on or off (though not necessarily if there’s rollover from one System Control key to another). What I think is going on is that the system is responding to the System_Sleep key’s “on” report, but then system goes to sleep before it gets the “off” report, and when it wakes up, it still hasn’t received it, so it immediately goes to sleep again. I guess there’s a problem in the HID code somewhere, possibly even in the Arduino library. Or maybe it’s a bug in the OS.
The Consumer Control HID protocol is more full-featured (up to four keys active at a time), and is handled better by the OS.
I’ll take a look at the System Control code in KeyboardioHID, but I honestly don’t expect to find a solution there.