"lock" keyboard and trackpad?

Is there a way to lock both the keyboard and the trackpad on a Mac laptop with KM?

I found a program that can do it, but then I got curious whether or not KM could do something like this.

Sample use case: you show a movie on your laptop for your toddler to watch, and you don't want them to accidentally do something by banging on the keyboard/trackpad

I supposed I could create a macro that's triggered by every single key, and do a test for a specific sequence to deactivate it or something. But is there a better way?

And how would I "capture" mouse/trackpad clicks?

There are several programs that can probably do this.

There may also, possibly, be some settings in macOS defaults that can turn off some devices, but I'm not sure about the default devices, which is what you are talking about.

Since your target is to "fool a toddler", I think I can accomplish this for the trackpad fairly easily. A trackpad is essentially just a mouse, and it's fairly easy to disable hit by moving it to the upper left corner of the screen constantly until something happens, like pressing the shift key. Maybe like this:

image

Effectively, that disables the mouse/trackpad.

I've done that once or twice before, but don't forget you can also use a typed string trigger with a wildcard trigger that will capture "most" of the keys on the keyboard with a single action. Hmm... I'm not sure that will work, because it probably doesn't gobble the key. You may need to use a pile of hotkeys, like this:

Of course, turning off these macros is a separate problem which I am not addressing until you tell me if you like these approaches.

That's a good idea!

Yes, that's pretty much what I had in mind for the keyboard.

And actually, combined with the mouse action, I guess the entire thing can be disabled with a single combination of modifiers or something like that.

Yes, it sounds like you are fully capable of coming up with a disabling mechanism and finding a trigger for it.

You might even want two triggers for disabling it, since if one doesn't work, you may have to do a cold reboot.

Maybe not worth spending money for this, but if a Bluetooth mouse or trackpad is readily available, the Mac can be set to ignore the built-in trackpad when the Bluetooth device is connected. That option is in Settings > Accessibility > Mouse & Trackpad.

@Airy Thanks for your help. I ended up creating two macros:
Macro 1 has every key as a hotkey, plus cmd-Q and cmd-W just in case. Whew, I didn't do key combinations like shift, ctrl, opt, cmd, but will consider adding these if my luck is that bad.

Macro 2 has your "move mouse to the corner" idea, triggered by ctrl-A and stopping when I type a combination of ctrl-opt-cmd.

It seems to work great in testing.

@NaOH I like that idea too. I can take the mouse with me or just turn it off.

Turning the mouse off (or getting too far away) will disable the system setting. The trackpad will only be disabled when the Bluetooth mouse is connected.

Got it. I can just put it out of reach then.