Apple - Adjusting brightness on 27" iMac used as external DisplayPort monitor for PC

I just had an issue with not being able to change the brightness on my 27inch iMac in Target Display Mode. It was at full brightness. And the brightness keys on the keyboard hooked up to the TDM Mac would not adjust it. But I found if I pressed and held Commond-F1 on that keyboard it slowly lowered the brightness. This probably won't help much if you have an issue with it defaulting to a low brightness though.

iMac 2009 High Sierra and iMac Pro Mojave.

I had the problem of brightness stuck on maximum when using a 27" late 2009 iMac (running High Sierra macOS 10.13.6) as an extra screen (in target display mode) using a MacBook Pro 15in (2018) running macOS Catalina 10.15.3. The iMac had an Apple wireless keyboard connected, and the macBook Pro was connected to the iMac via a USB-C to mini displayport cable (i.e. in target display mode). The display on the iMac toggled from the iMac in the normal mode to being an extra display for the macBook using command-F2 on the wireless keyboard. I found that the brightness control keys on the wireless keyboard (F1 and F2) for the iMac in target display mode only worked when I was logged into an account on the iMac. If the iMac was restarted, and nobody was logged into it, the brightness keys on the wireless keyboard did nothing. So when you start the iMac you need to log in to it before putting it into target display mode.