In certain situations, like pressing random keys of your keyboard automatically or you are using an external keyboard, and no need of your laptop inbuilt keyboard then you can disable laptop keyboard by using below method.
Disable Laptop Keyboard in Ubuntu
1) To Disable the laptop keyboard in Ubuntu, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
Then you can see a list of input devices, including keyboard which are currently attached to your laptop.
AT Translated Set 2 keyboard and take note of its
id number; this will be used to disable the keyboard. Also, take note of the number at the end,
[slave keyboard (#)]; this is the id number of the
master, which will be used to re-enable your keyboard
3) To disable the keyboard, run the command
xinput float <id#>, where
<id#> is your keyboard’s id number. For example, in above screenshot the
9, then the command would be
xinput float 9
How to enable keyboard again
To re-enable the keyboard, execute the command
xinput reattach <id#> <master#>, where
master is that second number we noted down. So if the number was
3, you would do
xinput reattach 9 3
Disable Laptop Keyboard in Windows
1) Open Device Manager in your laptop , expand the Keyboards section.
2) The keyboard arrow marked in red is the inbuilt keyboard your laptop has. (Your laptop’s keyboard might have a different name)
3) Now connect your wireless keyboard.
You will see another keyboard added under the keyboards section in device manager (arrow marked in green).
Again, your wireless keyboard would have a different name than mine (mine is wired). This is just an example.
4) Now right click on the inbuilt keyboard and click ‘uninstall’ (marked with red arrow).This will disable your inbuilt keyboard.
Do not panic as the inbuilt keyboard’s drivers would be reinstalled as soon as you restart the machine. However, uninstall the inbuilt one only after you have plugged in your wireless one.
Command below if you face any issues while doing this operation.