I have a SOHO setup where I use a USB keyboard and a USB mouse connected to my MacBook. The placement of the USB keyboard relative to my MacBook is as shown in the picture:

I primarily use the external USB keyboard for all my typing needs.

However, sometimes I need to type using the MacBook's built-in keyboard. Due to this particular arrangement, it's inconvenient to type without unintentionally pressing keys on the USB keyboard.

I find it a bit tedious to move the USB keyboard aside or unplug/plug the cable repeatedly during my workflow.

I am looking for a way to programmatically disconnect/reconnect the USB keyboard. Any hidden settings, scripts, Terminal commands are welcome.

I'd prefer not to install any 3rd party software, but wouldn't mind it either if no built-in solution exists.

I am running macOS Mojave 10.14.5, but looking for a generalized solution that works independent of the version of macOS (not a hard limitation, not targeting ancient versions).

  • An alternative is a Bluetooth keyboard which you can disable and re-enable at will through the Bluetooth menu. Matias has a wide selection of Bluetooth keyboards. I've been using this model almost every day for a few years now and it is great! It lives up to the specs, too. I've only needed to recharge it once! – IconDaemon May 28 at 12:56
  • You could get a usb hub used to attach your devices. Disconnect up connector. – historystamp May 29 at 2:57
  • I did get a lot of hits on "macos deactivate usb port". I looked at five or six of them, but they end up writing about disabling file storage devices. perhaps looking at one of them you will hit gold. – historystamp May 29 at 22:17

You must log in to answer this question.

Browse other questions tagged .