I didn't want batteries, so I used these magnetic reed switches. There are other places to get them-
https://konnected.io/products/contact-sensor-recessed-magnetic-for-doors-or-windows
You just gotta figure out power. I'm fortunate to own my home that has an attic and a crawlspace so drilling holes and pulling wire is simple.
Then I got a Shelly i4 DC. I think it's out of stock now but a Uni would work too. Shelly is all local, cloud disabled by default.
An ESPhome could do it also, and I wish I knew about esphome before I spent any money on importing the Shelly. Get a UNI and after you figure that out, get some esp32 dev boards from AliExpress.
Keyboards or ball joints?