I would like to know how one can disable the keyboard & mouse temporarily in OS X.
-
1Unplug them? OS X uses all USB devices, except for the bluetooth keyboard, which you can just turn off. – Keith Jul 21 '11 at 10:13
-
I need to do it programmatically, as I need to disable keyboard & mouse input while a certain program is running – Samantha Catania Jul 21 '11 at 10:19
-
That's a little odd. Are you sure you have to do that? – Keith Jul 21 '11 at 10:20
-
1Yes, I'm sure >.< It has something to do with remote login so if there is a person in front of your computer while you're remotely logged in they can't mess with your system – Samantha Catania Jul 21 '11 at 10:23
-
You mean like a remote desktop thing? – Keith Jul 21 '11 at 12:18
-
That is exactly why I need it – Samantha Catania Jul 21 '11 at 12:45
-
See [here](http://www.dumbentia.com/pdflib/stupida.pdf). seriously, I know of many ways to do it in windows, so there ought to be some equivalent in UNIX, I'l update soon. – Philomath Jul 21 '11 at 14:25
-
The lest edit here made my answer irrelevant, I will post the question with regard to ** UNIX** & re-post my answer – Philomath Jul 21 '11 at 20:29
-
5Related: [Similar question on typical unices (where the GUI is based on X)](http://unix.stackexchange.com/questions/17170/disable-keyboard-mouse-input-on-unix) – Gilles 'SO- stop being evil' Jul 21 '11 at 20:55
-
Over on superuser there's a similar question to this: http://superuser.com/questions/214221/how-can-i-lock-the-mouse-and-keyboard-but-see-the-screen – Colin 't Hart Jul 25 '12 at 19:13
6 Answers
Following on from what Jontas said...
Under Linux (I'm not entirely sure about OSX) you can use the xinput command to disable and enable specific devices. To get a list of device IDs just run the xinput command without any arguments. If $ID is the device ID then the following will disable it:
export DISPLAY=:0
xinput set-int-prop $ID "Device Enabled" 8 0
and this will re-enable it:
xinput set-int-prop $ID "Device Enabled" 8 1
I hope this is useful.
Since you like to do it progmmatically, I would recommend checking out http://alphababy.sourceforge.net/ and make a fork of that with the bits you need.
If you would do it without a program in-between I would say the hint about using "xinput set-int-prop [device_id] "Device Enabled" 8 0" from Disable Keyboard & Mouse input on unix (under X) would be better, but I understand it as that it is not what you are asking for.
Are you keyboard & mouse wireless or just USB? If first, disconnect them via Bluetooth menu on the OS X panel. :)
- 111
- 1
I have done this on linux (and I guess it shouldn't be that far out on Mac OS X) where I just unloaded the USB modules related to HID. usbhid was one such module
This would of course rended any hid devices unusable and you will need another way (like remote access) of getting access back.
Unplugging and plugging the keyboard/mouse may also restore service.
Under GNU/Linux systems running Xorg (on Wayland maybe will be different) you can use xinput as James R said, and as explained here: https://unix.stackexchange.com/a/17172/48798
On Mac OS X you can disable your keyboard using kextunload command like this:
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyb oard.kext/
(I've put there a typo intentionally, so you don't risk to issue this command unintentionally copying and pasting the text - you have to correct it and issue it on purpose)
To re-enable your keyboard use:
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
See also: https://discussions.apple.com/message/26569190#26569190
I don't know about the mouse (apart from unplugging, of course) but Keyboard Cleaner temporarily disables the keyboard.
- 183
- 1
- 5