However, by the time Apple released the 2014-2015Retina DisplayiMacs, they no longer supported the feature.
Connect the two Macs with either a Mini DisplayPort cable or a Thunderbolt cable.
When you are ready to exit Target Display Mode, pressCommand+F2or disconnect the iMac from the source Mac.

Pexels / Public Domain
This combination may work for some keyboard types.
check that the Mini DisplayPort or Thunderbolt cable is connected correctly.
A few third-party keyboards don’t send theCommand+F2prompt correctly.
Use another keyboard or the original keyboard that came with your Mac.
If a temporary need arises, sure, why not?
Remember, the rest of the iMac is still running behind the scenes, consuming electricity and generating heat.
If you need a large display for your Mac, grab a decent 27-inch or larger computer monitor.