USB Drive detection circuit
The Arduino library for DFPlayer includes a status for CardInserted and CardRemoved.

I assume they simply poll the USB key for presence.

Just read the code in the link above or at Github