67

Is it possible to completely disable the built-in keyboard on a MacBook? No input should be possible from that keyboard when I connect an external keyboard. This is sort of possible with the trackpad and the mouse, is there an option (or indeed a hack!) to do the same with the built-in hardware?

  • How about some of the solutions suggested in this similar superuser question? – binarybob Oct 14 '12 at 18:40
  • 1
    I started down the path of turning this into an applescript that would automatically toggle the internal keyboard on and off:

    sudo kextfind /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ 2> /tmp/keyboard-kext-out; if [ -s /tmp/keyboard-kext-out ]; then; echo "Kext is NOT loaded"; else; echo "Kext is loaded"; fi

    But I couldn't quite get it to work. Here's hoping that someone else with more motivation that me can pull that off.

    – timmfin Feb 06 '13 at 18:19

4 Answers4

59
  • Install Karabiner

  • Choose your external keyboards on Devices > Advanced.

    enter image description here

  • Check the corresponding box

Source

  • 1
    This seems a much bigger solution than necessary for such a simple task. – 2540625 Mar 30 '19 at 19:20
  • 18
    v12.2.0 has a convenient checkbox to automatically disable the internal keyboard when a different keyboard is connected. Now I can place my magic keyboard on top of my non-working-piece-of-trash butterflunk keyboard. Works like a charm! – jlmmns Apr 17 '19 at 07:49
  • 1
    Enabling this feature in Karabiner didn't work for me on 10.14 Mojave. Additionally, the latest version of Karabiner is called "Karabiner-Elements" and does not include this feature so I suspect it's been disabled by the underlying OS. – donturner Jul 04 '19 at 16:51
  • 4
    Complementing @jimmns, today in Karabiner, after connect the external keyboard, go to Karabiner Elements preference > Devices > Advanced.. now you can see the checkbox. – jeff_drumgod Feb 09 '20 at 14:18
  • 1
    Karabiner has been updated see the latest instructions here https://pqrs.org/osx/karabiner/document.html#disable-built-in-keyboard – Pnar Sbi Wer Feb 25 '20 at 14:58
  • 1
    Fixed URL: https://karabiner-elements.pqrs.org/docs/manual/configuration/disable-built-in-keyboard/ – juan Apr 13 '20 at 15:35
42

From Googling around, I found this page. It suggests that you unload a AppleUSBTCKeyboard.kext to disable keyboard:

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

This will prompt you for your password and then give some errors, but it does disable the built in keyboard (tested on my ML 10.8.2)

To re-enable the builtin keyboard, load the kext file again:

sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

BTW, I noticed that this immediately prints all that was typed on the builtin keyboard, so be ready for this (in Terminal this should probably just output some text).

For newer versions on MacOS / alternative solution:

List loaded kexts for keyboard

kextstat | grep Keyboard

It's going to output something like:

81    0 0xffffff7f833c5000 0xb000     0xb000     com.apple.driver.AppleHIDKeyboard (208) 96DDE905-9D31-38A9-96B7-FB28573587C8 <43 6 5 3>

com.apple.driver.AppleHIDKeyboard is loaded kext identifier.

If you want to plug-in Apple Magic Keyboard / some other Bluetooth keyboard, turn it off first. Then follow the instruction below.

To disable keyboard:

sudo kextunload -b com.apple.driver.AppleHIDKeyboard

To enable it back:

sudo kextload -b com.apple.driver.AppleHIDKeyboard
Laas
  • 618
  • 6
    Does this still work for you on OS X Mavericks 10.9.1? It used to work for me before, but now I'm getting:
    (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).
    
    – john2x Dec 20 '13 at 02:15
  • 3
    I’m getting the same error as @john2x but it does seem to be working despite the warning. – Leo May 16 '14 at 17:34
  • Yes working for me too on 10.9.4 despite the warning. – laurent Aug 05 '14 at 18:02
  • 2
    Just a quick note that this also works under Yosemite, despite the warnings. – snipe Oct 24 '14 at 03:54
  • 2
    This seems to cause a kernel panic on El Capitan Public Beta. – kettlepot Jul 11 '15 at 16:41
  • 1
    Yeah this stopped working for me too only recently. I need to disable it because I can't afford to get my laptop fixed yet and occasionally it types random keys while a large chunk of them have stopped working altogether. So I use a BT keyboard for now. But it worked fine up until a few weeks ago. I get the same message john2x gets. Something about it being in use or retained. I'm almost tempted to delete the AppleUSBTopCase.kext bundle itself as a last resort but I don't know what else it might control. So of course I don't take the risk. – Jason Anderson Jan 30 '17 at 22:51
  • 3
    Not working for me: (kernel) Kext com.apple.driver.AppleUSBTCKeyboard not found for unload request. Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) not found. – tdc Jan 13 '20 at 20:33
  • This is working on Mojave on an ancient MBP (early 2013) – Kristen Waite Jan 04 '21 at 15:38
  • not working on big sur, late 2016 mbp 15, same error as @john2x – Marku Jun 12 '21 at 15:58
4

There is a little utility called Keyboard Cleaner and it seems to work fine for me on 10.10.5. You run the program and only cmd + q stay functional to then quit it.

http://jan.prima.de/~jan/plok/archives/48-Keyboard-Cleaner.html

1

KeyboardCleanTool is like Keyboard Cleaner, but instead of dropping a curtain that takes all the strokes, it disables it through Accessibility API. Main advantage is it also blocks media keys and doesn't produce sounds when keys are hit. Nothing works except power button.

  • My only complaint is minor, that it doesn't also disable the trackpad for cleaning. I'd rather it unlock by a command-key combination. – 2540625 Mar 30 '19 at 19:29
  • I just tried keyboardcleantool. It only blocks the keyboard while the app is in the foreground. If you switch to other apps, the keyboard is not blocked. – Quinn Comendant Apr 18 '19 at 18:23
  • @QuinnComendant just tried it and I'll have to disagree on that. I'm on 10.13, so APIs might have changed in newer OSes. – seeker_of_bacon Apr 18 '19 at 19:41
  • @seeker_of_bacon I'm on 10.13.6, and I can't get it to work. It's pretty simple software, I don't think I could be using it wrong. Instead, I installed Karabiner-Elements and it works great; auto-disabling when an external keyboard is attached is really useful. – Quinn Comendant Apr 24 '19 at 05:30