I'm sorry but this is the ultimate definition of a solution looking for a problem.
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.
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.