How to lock and unlock keyboard in Ubuntu ?
xtrlock
might be what you're looking for. It disables the keyboard until you type your password. It does also disable the mouse, but you might be able to change that in the config. Install it by running sudo apt-get install xtrlock
.