Have you thought about using a NFC chip as an sliding switch. When sliding out the keyboard, the distance between the chip and the NFC receiver is to big to detect the NFC chip.