Attach and detach USB HID for XIAO SAMD21

I am using the HID library Keyboard.h. I would like to programmatically enable and disable the HID interface, so that the computer sees a keyboard or not depending on whether I have a switch on or off.
The built-in Keyboard.begin() and Keyboard.end() functions would be perfect, except that they don’t actually have any code in them.