Apple’s revamped iMac didn’t come with the option of a Magic Keyboard with Touch Bar as I anticipated. However, you can add one thanks to the Duet Display app.
The app — well, actually, it’s two apps: one for your Mac and one for your iOS device — allows you to use your iPhone or iPad as an extra display. I use it as a secondary display — with a “virtual” Touch Bar — with my iMac.
First, install duet for iOS. The latest version is 1.4.1 and requires iOS 8.0 or later.
After installation, you'll see the icon n your iDevice’s home screen. Tap on it to open when you want to use duet.
Next, you need Duet for Mac. It’s available at the product website for $9.99 and requires macOS 10.12.2 or higher (for the “Touch Bar” feature) on a Mac. The app will move to Applications and ask for your permission to add a graphics driver. The driver is required to render the high performance display on your iPad. The installation will only add an additional driver for Duet's operation and won’t affect your current system drivers.
Once the driver and app is installed, restart your Mac. After rebooting, you should see Duet's icon, a circle with a lowercase “d,” running in the menu bar. You can access Duet settings by clicking on this icon and then the settings gear inside the status window.
Start duet on your Mac and on iOS and connect your iPad or iPhone to your Mac using a 30-pin or Lightning cable. When duet detects the iPad or iPhone it will change the message from Connect to Mac to Launching Duet right before your new desktop is displayed on the Mac.
Duet Display taps into the appropriate code and models a "virtual" Touch Bar on a connected iPad. As with a real Touch Bar, it adapts to the active Mac app.