Target Display Mode went away when the first 27" 5K Retina iMac came out in Late 2014, and never returned.
Five 27" iMac models support Target Display Mode.
- 27" iMacs from Late 2009 and Mid 2010 support it – using Mini DisplayPort input.
- 27" iMacs from Mid 2011, Late 2012, and Late 2013 support it – using Thunderbolt 1 input.
Apple placed a bunch of restrictions on Target Display Mode. For instance, no Mac that's being sold today will support using any iMac as a Target Display. So odds are that you can't use it at all.
Use your iMac as a display with target display mode - Apple Support
If by some miracle you can, you don't get access to anything but the screen.
"The other Mac can't use the iMac computer's built-in camera or ports. To use external devices with your other Mac, connect them directly to the other Mac, not to your iMac."