Yeah, it’s surprisingly simple to get these microcontrollers to become essentially programmable keyboard/mouse emulators, by which point if you’re familiar with the stuff to program them (Arduino being the simplest and most widespread framework) it really just becomes a coding task and you can get it to do crazy stuff.
I suggested an Arduino Micro board because it bypasses the whole hardware side of the problem, but something like what you mention is even simpler.