14

Without unplugging my keyboard I'd like to disable it from the terminal; I was hoping that this could be done using rmmod but based on my currently loaded modules it doesn't look like it is possible.

Does anyone have any ideas?

  • 1
    The HID ("human interface device") module is probably built-in. Some of the USB stuff may not be tho, so you could try pulling one of those (lsmod | grep usb). – goldilocks Sep 17 '13 at 16:04
  • Hmmm: http://wpkg.org/Disable_/_enable_keyboard_and_mouse_in_Linux – goldilocks Sep 17 '13 at 16:05

1 Answers1

18

There are pretty good directions on doing it here, titled: Disable / enable keyboard and mouse in Linux.

Example

You can list the devices with this command.

$ xinput --list
"Virtual core pointer"  id=0    [XPointer]
"Virtual core keyboard" id=1    [XKeyboard]
"Keyboard2"     id=2    [XExtensionKeyboard]
"Mouse2"        id=3    [XExtensionKeyboard]

And disable the keyboard with this:

$ xinput set-int-prop 2 "Device Enabled" 8 0

And enable it with this one:

$ xinput set-int-prop 2 "Device Enabled" 8 1

This only works for disabling the keyboard through X. So if you're on a system that isn't running X this won't work.

List of properties

You can use this command to get a list of all the properties for a given device:

$ xinput --list-props 2
Device 'Virtual core keyboard':
    Device Enabled (124):   1
    Coordinate Transformation Matrix (126): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
slm
  • 369,824
  • 2
    Will it be reactivated if unplugged and plugged back in? Might be tricky to get a response from the machine (unless it's a laptop) otherwise :) – terdon Sep 17 '13 at 16:13
  • Yeah these disable device questions always seem loaded for the "ok so how do I re-enable it" piece. – slm Sep 17 '13 at 16:15
  • I would add that this disables the keyboard only for X11 and not for any TTY. Also you can still switch to the TTYs with Ctrl+Alt+F? – Raphael Ahrens Sep 17 '13 at 16:33
  • @RaphaelAhrens - yeah I said that in the answer, but thanks for re-iterating it. – slm Sep 17 '13 at 16:34
  • 2
    @terdon Make sure you have a working SSH connection before experimenting. – Gilles 'SO- stop being evil' Sep 17 '13 at 22:37
  • 1
    Can we not use xinput float <id> and xinput reattach <id> <master>? Is it any different? It feels intuitive though. – reza.safiyat Oct 28 '15 at 07:30
  • @reza.safiyat - if you have a new question, please ask it. You can reference this Q with yours being a follow-up or asking for more refinement. – slm Oct 28 '15 at 10:52
  • Not a new question, no. But just another method to do action. Is it any different? – reza.safiyat Oct 28 '15 at 11:47