On my 2011 iMac with no TB cable connected I get no result using CMD+F2, so could it be the cable?
If target display mode doesn't work
If your iMac doesn't show the desktop of your other Mac, try these steps first:
Restart your iMac.
Restart the other Mac.
Unplug the Thunderbolt or Mini DisplayPort cable from the other Mac, then plug it back in.
Press Command-F2 on the iMac.
If that doesn't work, try these other solutions:
If you're currently logged in to the iMac that you want to use as a display, choose Apple menu > Log Out to return to the login window. Then press Command-F2 again.
Choose Apple menu > System Preferences, then click Keyboard. If ”Use F1, F2, etc. keys as standard function keys” is selected, target display mode uses Command-Fn-F2 instead of Command-F2. It might also help to use the keyboard that came with your iMac. Some third-party keyboards and older Apple keyboards don't support target display mode.
Make sure that your iMac is using macOS High Sierra 10.13.6 or earlier. You can't use target display mode with later versions of macOS, or with Boot Camp and Windows.