How to turn off display by pressing the power button of MacBook Pro 2016? (Changing the behaviors of the power buttons)

As far as I know there's no Apple supported method of changing the power button behavior like that.


Unfortunately, what you're asking cannot be done.

In fact both issues have been brought up before, numerous times here on Ask Different so it's technically a duplicate, but it's difficult to do a "double duplicate" so, see below for supporting links on each topic.

  • There's no way to disable the internal display

    • Can. MacBook Pro run in closed-display mode without physically. closing the lid?
    • Disable Macbook internal display
    • How to disable the Macbook internal display and only use the external display on Snow Leopard?
    • How to disable Macbook Pro internal display when using external monitors
    • Disabling MBP display with external monitor connected in Clamshell Mode
  • There's no way to remap the power button

    • Disable power button on 2015 MBP
    • How can I make the power button on my MacBook run a custom script?
    • User fingerprint sensor to control media playback
    • Completely disable the power button on my MacBook

However, this terminal tip is outdated (press to sleep is not default anymore)

The terminal tip that you referenced is not applicable to this question because it's about configuring the power button to put your Mac to sleep, not "turn off the display(s)." Those are two very different actions. The power button has to do with controlling the state of your Mac: on/off/sleep. The display's state of being on/off is not a setting you can control outside of "power."

Additionally, commands are not outdated simply because they're dated. They become dated when it no longer functions in subsequent changes like OS or hardware updates. Currently, the power button still controls sleep/hibernation. See: https://support.apple.com/guide/mac-help/log-out-sleep-restart-or-shut-down-mchlp2522/mac