Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3541

Raspberry Pi OS • Re: External Keyboard Disable/Enable

$
0
0
Hello again. I had a quick look around and found a slightly hacky way. First, `sudo apt install evtest`. Then use `libinput list-devices` to find out which input device is your keyboard, in my case it's `/dev/input/event0`. Beware that this will probably change if the device reboots or if the keyboard is unplugged/replugged, so you probably need to write a script to automatically parse out the device. Then, to disable the keyboard run `evtest --grab /dev/input/event0 >/dev/null 2>&1` (substituting in your device). To re-enable the keyboard just kill evtest.

labwc does have a builtin mechanism for disabling mice/trackpads, but sadly it doesn't work with keyboards.

Here's a one-liner which works for me to find the keyboard device and grab it, you'll need to replace the device name if it's not an official Pi keyboard

Code:

evtest --grab $(libinput list-devices | grep -A1 'RPI Wired Keyboard 1' | grep Kernel | head -n1 | tr -s " " | cut -d' ' -f2) >/dev/null 2>/dev/null

Statistics: Posted by cillian64 — Mon Nov 10, 2025 11:24 am



Viewing all articles
Browse latest Browse all 3541

Trending Articles