I found a way to do it with an old, white apple keyboard, haven't tested with others but it might work.
I used a tool called Karabiner from https://pqrs.org/osx/karabiner/. When you install it, enable following options to get Command + F2 to work:
F1..F12 to Functional Keys (Brightness Adjust, Music Control, etc)
- F1,F2 to Brightness Adjust
--- F1 to Brightness Down
--- F2 to Brightness Up
After enabling this option, hit Command + F2 having previously connected your macbook using thunderbolt cable. If you're lucky you'll have a new external display working!
As I understand it you want to alternate between using the iMac display to display a) itself b) a connected MBP c) a simultaneously connected Mac Mini
When you enter Target Display Mode, you do this on the target, i.e. the iMac. There is no option to tell the iMac which connected computer to display, if there are multiple connected.
According to Use your iMac as a display with Target Display Mode in the section Exit Target Display Mode it mentions,
"Your iMac also exits Target Display Mode if you disconnect the cable
that connects the two computers, or if you shut down or sleep either
computer"
I have since tested with a Late 2012 iMac 27", Late 2013 15" Macbook Pro, and a Mid 2011, 13", Macbook Air, all running Yosemite.
a) I first connected the MBP and iMac via Thunderbolt cable, and pressed Command-F2 on the iMac. This caused the iMac to go into target display mode and displayed the MBP.
b) I connected the Macbook Air, via a second Thunderbolt cable and this caused the iMac to exit target display mode (as both the Macbook Air and the MBP were not sleeping).
c) I put the MBP to sleep (by closing the lid), and pressed Command-F2 on the iMac. This caused the iMac to go into target display mode and display the Macbook Air.
d) I then alternated target display mode by alternately putting the Macbook Air and the MBP to sleep and pressing Command-F2 on the iMac.
This all seemed to work ok, except one annoyance and that was the iMac seemed to have a dim display every time I entered target display mode. I had to manually adjust the brightness of the iMac display, using the display settings.
NB: From step b) that you cannot have the two computers connected to the iMac awake at the same time and have the iMac in Target Display Mode. At least one of the computers connected must be sleeping. The linked Apple support page fails to mention that.
Best Answer
It's not possible to use Target Display Mode to connect a MacBook (Early 2016) to a 27" iMac (2011)
For the Mid-2011 through Mid-2014 iMacs, you need a Thunderbolt cable and Thunderbolt isn't available on the Early 2016 MacBooks
From the Thunderbolt Support Page
From the MacBook (Early 2016) Tech Specs Page:
Thunderbolt is not supported on this USB-C port.