Keyboard Lock: Lock your laptop keyboard while you clean it (Windows)
I built Keyboard Lock to disable my Windows keyboard with a single shortcut so I can wipe the keys without typing gibberish or closing open windows. Press Ctrl+Alt+K to turn off key input, and press it again when you finish.
Read the transcript
This is Keyboard Lock, the smallest tool I have built.
Wipe a keyboard while the laptop is on, and every key you touch types something into whatever is open.
So I built one shortcut. Control, Alt, K switches the keyboard off. Press it again, and it is back.
The mouse still works, a banner shows it is locked, and it unlocks itself after ten minutes if you forget.
It is one small C sharp file. It never stores, logs, or sends a single keystroke.
The problem
Wiping a keyboard while the computer is on means every key you touch types something, so you end up with gibberish in whatever window is open. I wanted one shortcut that switches the keys off while I clean and back on when I am done, in a tool small enough to read in full: a single C# file with no installer, no network access, no settings files and nothing to install beyond the .NET Framework that already ships with Windows 10 and 11.
What it does
- Turns keyboard input on and off with the Ctrl+Alt+K shortcut, a tray menu, or a double-click
- Keeps the mouse and trackpad active so you can always restore typing from the tray icon
- Automatically restores keyboard input after 10 minutes so you cannot get locked out permanently
- Releases modifier keys (Ctrl, Alt, Shift and Windows) on activation to prevent stuck keys
- Displays a warning sign on the tray icon and shows a notification while keys are turned off
- Never records, stores, or transmits keystrokes anywhere
How it works
Keyboard Lock uses a Windows low-level keyboard hook, a built-in operating system mechanism that checks key presses before applications receive them, to decide whether to let a key through or swallow it. When active, it stops keyboard signals from reaching open programs while letting mouse and trackpad events pass through normally.
The entire program is written in a single C# source file of about 140 lines. It runs locally as a system tray program (the icon area near the clock) with no network access, no configuration files, and no dependencies beyond the .NET Framework included with Windows 10 and Windows 11.
Get started
Build from source
& "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /nologo /target:winexe /out:KeyboardLock.exe /reference:System.Windows.Forms.dll /reference:System.Drawing.dll KeyboardLock.csRun this command in PowerShell to compile KeyboardLock.exe using the built-in Windows C# compiler.
Start the app
Launch KeyboardLock.exe to display the keyboard icon in your system tray.
Turn off keys to clean
Press Ctrl+Alt+K to turn off keyboard input and safely wipe your keys.
Restore keyboard input
Press Ctrl+Alt+K again or double-click the tray icon to get your keyboard back.
Exit the app
Right-click the tray icon and choose Exit when you want to quit.
macOS and Linux (beta)
Keyboard Lock now also has macOS and Linux versions with the same Ctrl+Alt+K shortcut (Control+Option+K on a Mac), the same 10-minute auto-unlock and a working mouse. They are in beta: built and checked with automated tests, but not yet tested on real Mac or Linux hardware.
bash setup.sh
bash launch.shOn a Mac, allow Accessibility and Input Monitoring for the terminal in System Settings, then relaunch. On Linux, your user needs access to keyboard input devices, usually by joining the input group:
sudo usermod -aG input "$USER"The full steps and known limits are in the README.
Requirements
- Windows 10 or Windows 11
- .NET Framework (ships with Windows 10 and Windows 11)
- PowerShell (to compile the source file)
- macOS (beta): macOS 11 or later and Python 3.9 or later
- Linux (beta): Python 3.9 or later and access to /dev/input devices
Questions
How do I disable my laptop keyboard while cleaning it on Windows?
Run Keyboard Lock and press Ctrl+Alt+K. Every key is blocked until you press the shortcut again or 10 minutes pass.
Can I lock the keyboard but keep using the mouse?
Yes. The mouse and trackpad are untouched, so you can still restore typing from the system tray icon.
Does it work on Windows 11?
Yes. It works on Windows 10 and Windows 11 using the standard Windows low-level keyboard hook.
Is it a keylogger?
No. It never records, stores, or transmits key presses, and the code has no file or network access.
Why does antivirus software show a warning for KeyboardLock.exe?
Any program that watches keyboard input can look suspicious to antivirus software. The executable is unsigned, but the single C# file is short and open so you can inspect all of it before compiling.