I have an older iMac which I am retiring as a display. It works well enough in target display mode, but I have keep the keyboard around just to switch it to display mode.

Is there a way to

  • boot the iMac into target display mode
  • start target display mode remotely, such as from the console?
  • were you able to solve this? Nov 23, 2021 at 2:48
  • @simplegamer Not reliably. I did try VirtualKVM, and it sometimes worked. I now keep an old keyboard in the draw. All of this will soon be moot, as current model Macs don’t support target display, so I’m looking at alternmative solutions such as Luna Display from Astropad.
    – Manngo
    Nov 23, 2021 at 2:58

5 Answers 5


There are two options that I'm aware of which may meet your needs:

  1. Use the 1Keyboard app. This allows you to pair your computers via bluetooth and then use 1Keyboard to send the CommandF2 keyboard shortcut. It basically allows you to use one keyboard with multiple devices.
  2. Use VirtualKVM. This was designed specifically for people wanting to use their iMacs in target display mode, and works especially well in situations where you want to connect a MacBook to the iMac. For example, if you plug your MacBook into your iMac via Thunderbolt, this extention will automatically switch the iMac to Target Display Mode, allowing you to use your iMac as a monitor. It also switches off the Bluetooth on the iMac, freeing up your mouse and keyboard to pair with your MacBook (assuming you're using a bluetooth keyboard and mouse). When you unplug the MacBook, the iMac's Bluetooth will be powered back up and the monitor restored.

The above options should work fine. If you're a more advanced user, you could also check out this Super User question.

  • 2
    Option 1 did not work for me using macOS Mojave 10.14.5 and 1Keyboard version 2.6.
    – Johan
    Jul 22, 2019 at 10:09
  • 1
    None of the options work. 1Keyboard doesn't work when the Target Display Mode is on, once the Target Display Mode is disabled, 1Keyboard starts to work again. And Virtual KVM needs a keyboard connected to switch to Target Display Mode, if no keyboard is connected, it just turns off the Bluetooth on the iMac but doesn't trigger the Target Display Mode change.
    – ElChiniNet
    Apr 26, 2020 at 16:26

You can start Target Display Mode via SSH from other macs in the local network.

  • 1
    That is a modified version of this one, and as it states: As far as I know you need an official Apple keyboard connected when you’re running these scripts, even if you’re emulating the keyboard commands with code.
    – ElChiniNet
    Apr 26, 2020 at 16:37

I was actually researching the same problem today and found a solution to the remote switching issue.

Apple Keyboard Emulator to switch remotely switch Target Display Mode of an iMac without a physically connected keyboard Problem What you need Step 1:

Download and install the Arduino IDE (I did this with version 1.8.12)

Step 2:

Modify the Arduino Leonardo board description in /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/boards.txt in the Arduino IDE app package to include the necessary USB descriptor to match the following:

leonardo.name=Arduino Leonardo



leonardo.build.usb_product="Apple Keyboard"
leonardo.build.usb_manufacturer="Apple Computer, Inc."
Step 3:

Start/restart the Arduino IDE, open an example sketch for the keyboard library (I used the Keyboard Message Send example). Plug in the Arduino Leonardo compatible board and upload the sketch. Plug the Arduino into the iMac to be used in Target Display Mode

Step 4:

Create a script (here I named it switchTDM.sh) to send the CMD+F2 keyboard command telling the iMac to switch in or out of Target Display Mode. Put this script in the user directory (/users/<USERNAME>).

# switchTDM.sh script
osascript -e 'tell application "System Events" to key code 144 using command down'
echo 'Sent TDM switch signal.'

Modify the script to be executable:

chmod +x switchTDM.sh
Step 5:

Enable SSH access to the TDM iMac by enabling "Remote Login" in the sharing options of the System Preferences. And test whether you can login from a remote machine using:

ssh <USERNAME>:<PASSWORD>@<IP or hostname of iMac>
Step 6:

Bind the call to the remote script to a keyboard shortcut. I use BetterTouchTool: Add a new keyboard shortcut and execute the following terminal command:

ssh <USERNAME>:<PASSWORD>@<IP or hostname of iMac> ~/switchTDM.sh
That's it

Use your defined keyboard shortcut to switch your iMac in and out of Target Display Mode.


I was able to switch it with just a mouse connected. Source

  1. Go to System Preferences > Keyboard.
  2. Check the box that says "Show keyboard and emoji viewers in menu bar."
  3. Click the icon in the Menu Bar with the Command () symbol in it, and choose "Show Keyboard Viewer."
  4. The keyboard will show up on your screen. You can click on letters to insert them in documents, or watch them become highlighted when you type on the actual keyboard.
  5. Double click on Cmd and then click on F2.


  • the double click does not seem to engage a key combination, F2 or otherwise. For example, I can't even CMD + C to copy some text with the clickable keyboard. This really worked for you?
    – Esten
    Nov 18, 2020 at 18:01
  • Same comment as Esten Nov 23, 2021 at 2:18

forget it! you can't enter target display mode without a physical keyboard connected on your iMac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .