Based on https://stackoverflow.com/a/57776820/2654603 I am using the IOBluetooth framework to detect disconnect/reconnect of my keyboard, such that switching it
IOBluetooth