The actual hack.

When the key event fires, if it happens to be the lid switch, then IF (the state of the keyboard is "opened", AND the button backlight is already ON), turn on the keyboard backlight, ELSE turn off the keyboard backlight.