Ubuntu – How to disable and enable keyboard in ubuntu

keyboardshortcut-keys

How to disable and enable keyboard in ubuntu?

I have a great trouble because I don't have enough space to put both my keyboard and some other things on my desk. And accidentally pressing some key may cause trouble to the system. So I am looking for one way to lock my keyboard temporarily. Of course I don't want to plug out the keyboard from the computer because it is so inconvenient.

How can I do with this?

xinput -list

⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Optical Mouse                id=9    [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ CHICONY HP Basic USB Keyboard             id=8    [slave  keyboard (3)]
    ↳ HP WMI hotkeys                            id=10   [slave  keyboard (3)]

Best Answer

To Disable/Enable the keyboard, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

xinput -list

enter image description here

Once you find your ID, then

sleep 0.1 ; xinput set-prop 9 'Device Enabled' 0 ; sleep 5 ; xinput set-prop 9 'Device Enabled' 1

sleep 5 is the number of seconds (I guess) you want the keyboard to be disabled.

For more information on the xinput command see the ManPage.

Or you can use Lock keyboard utility.