For anyone that found this thread using a search with questions about Target Display Mode compatibility, see the following:
Late 2009 - Mid 2010 iMacs, Only the 27" will work as the target Mac. Should work with any Mac that is capable of outputting Mini Display Port. Also should work with non-Apple devices, as long as they can output DP. Works with AS Macs as well.
Mid 2011 - Late 2013 iMacs, Both 21" and 27" can work as the target Mac. Only works with other Intel Macs with Thunderbolt.
Mid 2014 iMac, Only 21" can work as the target Mac. Only works with other Intel Macs with Thunderbolt.
Notes:
M1 and up Macs will not work as the source Mac with the Mid 2011 to Mid 2014 iMacs. They do work with the Late 2009 to Mid 2010 27" iMacs.
The recommended OS for the target iMac is High Sierra, although, TDM could work with other OS versions.
Some non-OEM keyboards will not work to enable TDM on the target Macs, this includes Apple Keyboards. If TDM is not working with otherwise compatible equipment, you may need to use the keyboard that originally came with your target iMac.