You can try 2 options
- This free app KeyboardCleanTool, I do not have an external keyboard so I don't know if it disables too.
Running the following commands.
Disable:
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
Enable:
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
Although when you disable the keyboard the following message shows up, the keyboard remains disabled:
(kernel) Can't unload kext com.apple.driver.AppleUSBTCKeyboard; classes have instances:
(kernel) Kext com.apple.driver.AppleUSBTCKeyboard class AppleUSBTCKeyboard has 1 instance.
Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) kext is in use or retained (cannot unload).
I tried both options and both work.
Note: Consider that those commands should be running as administrator, the sudo command "saves" password for a limited time and you can run other commands between this timespan, but when the time is over the terminal asks for the password again and if you do not have an external keyboard you can not type the password until you restart the macbook.
Source: This post answers