keys as standard functions keys, the key combination changes to Command-Fn-F2.
If your iMac doesn't switch to Target Display Mode when you press Command-F2, check these things: Use your iMac as a display with Target Display Mode - Apple Support To troubleshoot this situation, we recommend that you read over the information in the following article, especially the “If Command-F2 doesn’t work” section. We understand from your post that you have used Target Display Mode before in the past, but after upgrading to macOS Sierra, it is no longer functioning with the Command-F2 command as you would expect.
Welcome to the Apple Support Communities!