MacBook Pro won't recognize USB keyboard any more

I have a "MacBook Pro (Retina, 15-inch, Mid 2015)" running Mojave (v10.14.5).

I'm trying to use a Microsoft Natural 4000 v1.0 USB keyboard, because it's one of the few keyboards that fits my hands comfortably.

One of my quirks is that I'm a heavy user of the command line and Emacs, and my fingers know that the key to the left of the "A" is supposed to be a control key.

Up until last night, it was working fine. However, something broke when I had my laptop away from power and my USB hub and let the Mac drain so much that it shut down.

When I restarted it this morning after being plugged in all night, it wouldn't recognize my external USB keyboard as anything other than a generic keyboard; for example, this dialog box in System preferences used to show something like "Natural® Ergonomic Keyboard 4000" but now shows just "Keyboard":

System Preferences Modifier Keys dialog

This wouldn't be so bad, except that now I can't get the Caps Lock key to behave as a Control key. When I choose in "Modifiers" to get it to behave as "Control", what happens is that it becomes a Control Lock key, not a Control key: that is, pressing the key to the left of "A" and then releasing it will make every key after that act as if Control is held down, until I hit that key again. I've double-checked and I don't have "Sticky Keys" set. (Besides, on the keyboard that's part of my laptop this works correctly: there, the key to the left of "A" behaves as a control key should. It's only a control lock on my USB keyboard)

Clearly some part of the system knows that it is not just a generic keyboard; here's a snippet from system_profiler SPUSBDataType:

    Natural® Ergonomic Keyboard 4000:

      Product ID: 0x00db
      Vendor ID: 0x045e  (Microsoft Corporation)
      Version: 1.73
      Speed: Up to 1.5 Mb/sec
      Manufacturer: Microsoft
      Location ID: 0x14200000 / 6
      Current Available (mA): 500
      Current Required (mA): 100
      Extra Operating Current (mA): 0

I've tried deleting the com.apple.HIToolbox.plist file from both /Library/Preferences and ~/Library/Preferences and deleting the /Library/Preferences/com.apple.keyboardtype.plist file. I've tried reseting the PRAM with Command-Option-P-R at boot. None of this has allowed the Mac to recognize my keyboard again.

Here's the output of kextstat | grep -v com.apple:

Index Refs Address            Size       Wired      Name (Version) UUID <Linked Against>
  167    0 0xffffff7f838e9000 0x4000     0x4000     com.protech.NoSleep (1.5.0) CB8F75A7-9009-31D3-A758-8C157CFEA5EC <6 5 3>
  168    0 0xffffff7f838ed000 0x4000     0x4000     com.paloaltonetworks.kext.pangpd (1.0.0) 2EB7232F-AC35-3CB5-81B3-D81783A18EEF <6 5 3 1>
  169    1 0xffffff7f8222e000 0xf000     0xf000     com.microsoft.driver.MicrosoftKeyboard (8.2) F2145396-D787-803F-EA32-59BCD2024DDD <43 6 5 3>
  170    0 0xffffff7f8223d000 0x3000     0x3000     com.microsoft.driver.MicrosoftKeyboardUSB (8.2) 97C6123F-A83C-7B6E-5109-210C185B5AA1 <169 54 43 6 5 3>

Solution 1:

Success!

After I posted this, I tried a few more keywords in my Googling and found this: How to map Caps Lock as a second Control Key on a Microsoft Natural Ergonomic Keyboard 4000?

And it turns out that uninstalling the Microsoft drivers (by running the programs in Applications/Utilities called "Intellitype Uninstaller" and "Intellipoint Uninstaller") did the trick.

I don't know why the Microsoft drivers worked fine for years and only broke last night, but my keyboard is now properly recognized as what it is and I didn't even need to adjust the setting in the "Modifier Keys" dialog in the Keyboard System Preferences: it remembered what it should be, and once again shows my keyboard as a "Natural® Ergonomic Keyboard 4000" and not just a generic "Keyboard".