Keylock: Keylock: macOS utility to lock the keyboard for easy cleaning
github.com
github.com
Sorry you've wasted your time coding this because in reality the solution is already built into macOS: enable the "require passsword after screen saver begins" setting in system preferences.
When you need to clean the keyboard, just activate your screensaver (easily done via configuring a hot-spot). Job done.
However, I was motivated to do this work due to specific challenges I faced:
1. Keystroke Sensitivity: Accidental keystrokes interpreted as password attempts can be inconvenient, particularly the frustration of dealing with invalid password messages and unintended inputs in the password field.
2. Automatic Unlocking: My Apple Watch automatically unlocks my device, which is generally convenient. However, this feature can be counterproductive when cleaning my keyboard, as it leads to repeated unlocking. Although disabling this feature temporarily is an option, it disrupts my preferred workflow.
So I did this to allow hassle-free cleaning without altering existing security settings or device behaviours. It may seem redundant, but I think it offers some value for those with specific preferences or in unique situations. And the project was a quick (yet fulfilling) endeavour during my coffee-time break enhancing my workflow, so I shared it hoping it might assist others with similar needs as well. Therefore, considering the little time it took from me and its helpfulness for very personal case at least, I don't think it was a waste of time, but I value your point of view and appreciate your feedback. Cheers!
Feature request: create a maximized window with as little decorations as possible using a black background so we can clean the display too.
That's called sleep mode.