Keyboard shortcut flip screen How can I create a keyboard shortcut that flips my screen upside down?

I know how to enable this setting in System Preferences but I want to be able to bind it to a shortcut.

Is it possible to make the same keyboard shortcut revert the display back to normal orientation?
The following has been tested under macOS Sierra 10.12.5 and macOS High Sierra 10.13.3, and works without any issue on my system.
Using the example AppleScript code, from my original answer, saved as an AppleScript application named Flip Display 180° and added to System Preferences &gt; Security &amp; Privacy &gt; Privacy &gt; Accessibility, so as to allow it to process the code, I then used an Automator service workflow, also named Flip Display 180°, to open the AppleScript application of the same name, while assigning the following keyboard shortcut:  ⇧⌃⌘R

Note that the keyboard shortcut ⇧⌃⌘F, which worked under OS X 10.8.5, conflicted with a system default keyboard shortcut under macOS 10.12.5, macOS 10.13.3 and why I changed it. You may have to use a different keyboard shortcut and as usual you have to choose one that isn't already assigned in any application that has focus when pressed to activate this Automator service workflow.

I also ran the following command, in Terminal, so as not to show the Dock Tile for the AppleScript application on the Dock:
  defaults write '/Applications/Flip Display 180°.app/Contents/Info.plist' LSUIElement -bool yes



That said, if the UI for Displays in System Preferences in macOS High Sierra on your system different for some undisclosed reason then the example AppleScript code will need to be modified to accommodate the the differences between what works on my system and yours. If it does need to be modified, I'd imagine it wouldn't be that hard to figure out.

The following images show the relevant details:
System Preferences &gt; Displays &gt; Display, as shown on my system:

AppleScript application, named Flip Display 180°:

Automator service workflow, also named Flip Display 180°:
Code: open -a 'Flip Display 180°'

System Preferences &gt; Security &amp; Privacy &gt; Privacy &gt; Accessibility:

System Preferences &gt; Keyboard &gt; Shortcuts &gt; Services &gt; General &gt; Flip Display 180°


For the time being I'm leaving my original answer at the bottom portion of this answer as it does work as stated under OS X 10.8.6 and may be beneficial for other users.
Original Answer:
I know you are using macOS High Sierra and maybe you can use what works for me under OS X 10.8.6.
The following example AppleScript code used in a Run AppleScript action in an Automator service workflow flips the Display 180° when I press: ⇧⌃⌘F
if running of application &quot;System Preferences&quot; then
    quit application &quot;System Preferences&quot;
    delay 1
end if

tell application &quot;System Preferences&quot;
    reveal anchor &quot;displaysDisplayTab&quot; of pane id &quot;com.apple.preference.displays&quot;
    delay 1
    tell application &quot;System Events&quot;
        tell pop up button &quot;Rotation:&quot; of tab group 1 of window 1 of application process &quot;System Preferences&quot;
            if (value) contains &quot;Standard&quot; then
                click
                click menu item &quot;180°&quot; of menu 1
                my clickConfirmButton()
            else
                click
                click menu item &quot;Standard&quot; of menu 1
            end if
        end tell
    end tell
    quit
end tell

on clickConfirmButton()
    set wasClicked to false
    repeat until wasClicked
        delay 0.5
        tell application &quot;System Events&quot;
            try
                click button &quot;Confirm&quot; of sheet 1 of window 1 of application process &quot;System Preferences&quot;
                set wasClicked to true
            end try
        end tell
    end repeat
end clickConfirmButton


Note that the value of the delay commands may need to be adjusted for your system, and or additional delay commands may or may not be needed. Adjust values of and or add/remove the delay commands as appropriate.


Note: The example AppleScript code is just that and does not employ any other error handling then what's shown and is meant only to show one of many ways to accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.

Automator service workflow: