Is there any way I can lock my keyboard?

Hey there!
Is there any way I can lock my keyboard with a shortcut? Until I hit that shortcut again, none of the keys should work(preferably even the touchpad).
I want to use it as a security addition in case I don’t want to keep logging in with my password every time I leave for a few moments.


Kernel: 6.7.6-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
clocksource: hpet avail: acpi_pm
parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
root=UUID=c877fe9c-cef9-4c56-9812-62dcfec9364d rw rootflags=subvol=@
quiet loglevel=3 ibt=off
Desktop: KDE Plasma v: 5.27.10 tk: Qt v: 5.15.12 info: frameworks
v: 5.115.0 wm: kwin_wayland with: krunner vt: 1 dm: SDDM Distro: Garuda
base: Arch Linux
Type: Laptop System: LENOVO product: 21JRS00U00 v: ThinkPad E14 Gen 5
serial: <superuser required> Chassis: type: 10 serial: <superuser required>
Mobo: LENOVO model: 21JRS00U00 v: ThinkPad serial: <superuser required>
part-nu: LENOVO_MT_21JR_BU_Think_FM_ThinkPad E14 Gen 5
uuid: <superuser required> UEFI: LENOVO v: R2CET32W (1.14)
date: 11/27/2023
ID-1: BAT0 charge: 43.1 Wh (90.9%) condition: 47.4/47.0 Wh (100.9%)
power: 25.6 W volts: 13.1 min: 11.3 model: Sunwoda L22D3PG4 type: Li-poly
serial: <filter> status: charging cycles: 53
Info: model: AMD Ryzen 5 7530U with Radeon Graphics bits: 64 type: MT MCP
arch: Zen 3 gen: 4 level: v3 note: check built: 2021-22
process: TSMC n7 (7nm) family: 0x19 (25) model-id: 0x50 (80) stepping: 0
microcode: 0xA50000D
Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB
L3: 16 MiB desc: 1x16 MiB
Speed (MHz): avg: 2014 high: 2442 min/max: 400/4546 scaling:
driver: amd-pstate-epp governor: powersave cores: 1: 2373 2: 2363 3: 2370
4: 2395 5: 2360 6: 2355 7: 2442 8: 2395 9: 400 10: 400 11: 2007 12: 2309
bogomips: 47908
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Vulnerabilities: <filter>
Device-1: AMD Barcelo vendor: Lenovo driver: amdgpu v: kernel arch: GCN-5
code: Vega process: GF 14nm built: 2017-20 pcie: gen: 3 speed: 8 GT/s
lanes: 16 link-max: gen: 4 speed: 16 GT/s ports: active: eDP-1
empty: DP-1,DP-2,HDMI-A-1 bus-ID: 04:00.0 chip-ID: 1002:15e7
class-ID: 0300 temp: 55.0 C
Device-2: Chicony Integrated Camera driver: uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-3:2 chip-ID: 04f2:b7ba
class-ID: 0e02 serial: <filter>
Display: wayland server: v: with: Xwayland v: 23.2.4
compositor: kwin_wayland driver: X: loaded: amdgpu unloaded: modesetting
alternate: fbdev,vesa dri: radeonsi gpu: amdgpu display-ID: 0
Monitor-1: eDP-1 res: 1536x960 size: N/A modes: N/A
API: EGL v: 1.5 hw: drv: amd radeonsi platforms: device: 0 drv: radeonsi
device: 1 drv: swrast surfaceless: drv: radeonsi wayland: drv: radeonsi x11:
drv: radeonsi inactive: gbm
API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.0.1-arch1.1
glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (radeonsi
renoir LLVM 16.0.6 DRM 3.57 6.7.6-zen1-1-zen) device-ID: 1002:15e7
memory: 1000 MiB unified: no display-ID: :1.0
API: Vulkan v: 1.3.276 layers: 3 device: 0 type: integrated-gpu name: AMD
Radeon Graphics (RADV RENOIR) driver: mesa radv v: 24.0.1-arch1.1
device-ID: 1002:15e7 surfaces: xcb,xlib,wayland device: 1 type: cpu
name: llvmpipe (LLVM 16.0.6 256 bits) driver: mesa llvmpipe
v: 24.0.1-arch1.1 (LLVM 16.0.6) device-ID: 10005:0000
surfaces: xcb,xlib,wayland
Device-1: AMD Renoir Radeon High Definition Audio vendor: Lenovo
driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
link-max: gen: 4 speed: 16 GT/s bus-ID: 04:00.1 chip-ID: 1002:1637
class-ID: 0403
Device-2: AMD ACP/ACP3X/ACP6x Audio Coprocessor vendor: Lenovo
driver: snd_rn_pci_acp3x v: kernel alternate: snd_pci_acp3x, snd_pci_acp5x,
snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_pci_ps,
snd_sof_amd_renoir, snd_sof_amd_rembrandt, snd_sof_amd_vangogh,
snd_sof_amd_acp63 pcie: gen: 3 speed: 8 GT/s lanes: 16 link-max: gen: 4
speed: 16 GT/s bus-ID: 04:00.5 chip-ID: 1022:15e2 class-ID: 0480
Device-3: AMD Family 17h/19h HD Audio vendor: Lenovo driver: snd_hda_intel
v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 link-max: gen: 4
speed: 16 GT/s bus-ID: 04:00.6 chip-ID: 1022:15e3 class-ID: 0403
API: ALSA v: k6.7.6-zen1-1-zen status: kernel-api tools: N/A
Server-1: PipeWire v: 1.0.3 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Device-1: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
vendor: Lenovo RTL8111/8168/8411 driver: r8169 v: kernel pcie: gen: 1
speed: 2.5 GT/s lanes: 1 port: 3000 bus-ID: 02:00.0 chip-ID: 10ec:8168
class-ID: 0200
IF: enp2s0 state: down mac: <filter>
Device-2: Realtek RTL8852BE PCIe 802.11ax Wireless Network vendor: Lenovo
driver: rtw89_8852be v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1
port: 2000 bus-ID: 03:00.0 chip-ID: 10ec:b852 class-ID: 0280
IF: wlp3s0 state: up mac: <filter>
Info: services: NetworkManager, smbd, systemd-timesyncd, wpa_supplicant
Device-1: Realtek Bluetooth Radio driver: btusb v: 0.8 type: USB rev: 1.0
speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 3-4:3 chip-ID: 0bda:4853
class-ID: e001 serial: <filter>
Report: btmgmt ID: hci0 rfk-id: 9 state: up address: <filter> bt-v: 5.3
lmp-v: 12 status: discoverable: no pairing: no class-ID: 6c010c
Local Storage: total: 476.94 GiB used: 51.93 GiB (10.9%)
SMART Message: Unable to run smartctl. Root privileges required.
ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Western Digital model: WD PC
SN740 SDDQMQD-512G-1201 size: 476.94 GiB block-size: physical: 512 B
logical: 512 B speed: 63.2 Gb/s lanes: 4 tech: SSD serial: <filter>
fw-rev: 73116101 temp: 35.9 C scheme: GPT
ID-1: / raw-size: 244.33 GiB size: 244.33 GiB (100.00%)
used: 51.9 GiB (21.2%) fs: btrfs dev: /dev/nvme0n1p5 maj-min: 259:5
ID-2: /boot/efi raw-size: 260 MiB size: 256 MiB (98.46%)
used: 33.4 MiB (13.1%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
ID-3: /home raw-size: 244.33 GiB size: 244.33 GiB (100.00%)
used: 51.9 GiB (21.2%) fs: btrfs dev: /dev/nvme0n1p5 maj-min: 259:5
ID-4: /var/log raw-size: 244.33 GiB size: 244.33 GiB (100.00%)
used: 51.9 GiB (21.2%) fs: btrfs dev: /dev/nvme0n1p5 maj-min: 259:5
ID-5: /var/tmp raw-size: 244.33 GiB size: 244.33 GiB (100.00%)
used: 51.9 GiB (21.2%) fs: btrfs dev: /dev/nvme0n1p5 maj-min: 259:5
Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
ID-1: swap-1 type: zram size: 14.46 GiB used: 0 KiB (0.0%) priority: 100
comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 12 dev: /dev/zram0
System Temperatures: cpu: 61.0 C mobo: N/A gpu: amdgpu temp: 55.0 C
Fan Speeds (rpm): fan-1: 2200 fan-2: 2200
Memory: total: 16 GiB note: est. available: 14.46 GiB used: 7.83 GiB (54.1%)
Processes: 358 Power: uptime: 11h 27m states: freeze,mem,disk
suspend: s2idle wakeups: 7 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 5.77 GiB services: org_kde_powerdevil,
power-profiles-daemon, upowerd Init: systemd v: 255 default: graphical
tool: systemctl
Packages: pm: pacman pkgs: 1398 libs: 416 tools: octopi,paru Compilers:
gcc: 13.2.1 Shell: garuda-inxi default: fish v: 3.7.0 running-in: konsole
inxi: 3.3.33
Garuda (2.6.23-1):
System install date:     2024-01-06
Last full system update: 2024-02-27 ↻
Is partially upgraded:   No
Relevant software:       snapper NetworkManager dracut
Windows dual boot:       Probably (Run as root to verify)
Failed units:

In my opinion, a locked keyboard will no longer be able to respond to keystrokes, which is the purpose of a key lock. Right?

Unless you create a program that enables this key combination and locks all other keys.
Your search on the Internet to see if something like this already exists didn’t turn up anything?

1 Like

I would look for a usb fingerprint scanner and just lock the laptop like normal.

1 Like

But he should take the USB Stick with him when he leaves the laptop. If one of his children hides it, he will at least be separated from his data for a while.
A short, complicated password would be better.
Take 69()/ , I always use that :smiley:


I did look for that at first, but the current AUR package is broken.

Yeah, I did search for it. Nothing turned up. It would be simpler to just enable the fingerprint scanner, but the AUR package has issues. I decided not to mess around with it in case I break something.

Regarding the first question, I just want a certain set of keys, which, if pressed in unison, the system will accept it.

1 Like

Did you consider a security key like Yubikey for instance. You can lock computer and just remove it and nothing could unlock it until you insert the key back.
A simple version of it cost around $25 on Amazaon.
Like that:


Two existing packages that may or may not work are lk4b and xtrlock (likely, both X11 only though) .
There are many search results for similar functionality, but most are for X11 too.
A different case but the info may be of use: xinput - In a Wayland session, how to automatically disable input devices when the laptop lid is closed? - Unix & Linux Stack Exchange – one would also need a way to unlock the input devices, and that is something that has to happen without using the disabled devices of course.
Probably, plugging in a mouse or keyboard will do as they are different devices that were not disabled. Or maybe recognize the insertion of a USB key with some file on it.
GIven the “threat model” it doesn’t need to be anything really very safe, it’s one case where “security by obscurity” can be good enough.

update: there’s a catch with the method above, writing to inhibited requires root.
If using a simple script to be called again later when unlocking (as opposed to keeping it running) that would be a bad surprise when it prompts for a password.
One may configure sudo to allow the script to run without password though.
Or simply wait for the unlock event in the script. I’d suggest to inotifywait for some device node (a usb key used as unlock key) to appear, then possibly check some file on it (for added “security”), though the device label or uuid may be enough.


inhibit_input_devices() {
  while read -r line; do
    case "$line" in
      N:*) n="${line:8}" ;;
      S:*) s="${line:9}" ;;
       '') grep -Eiq 'keyboard|mouse|track' <<<$n && echo ${1:0} >/sys/$s/inhibited
  done </proc/bus/input/devices
inhibit_input_devices 1
sleep 5 # wait for event here
inhibit_input_devices 0

needs be run with sudo, and I’d add a trap to ensure unlocking if it fails midway for some reason. maybe later I update. As it is, it does lock my keyboard and mouse and unlock them after 5 seconds, not very useful, but a start.


A while ago we had a forum member here with a very impressionable nick (no not me) who stopped participating here but still has an account. I have that user’s nick as my laptop’s password. Gotta protect my lil bro from my laptop’s grandness… :wink: (that lil snitch will definitely blab to my parents everything he finds… I don’t wanna receive flying slippers at my age)


That’s why Garuda has snapshots :smiley:
I wouldn’t worry about breaking anything as long as you know your snapshots work and you can restore your system, unless it’s something firmware related to the scanner


if you temporarily lock your keyboard, you could still use an on screen keyboard to enter your password to unlock your computer/reactivate your keyboard.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.