For many years, I was using a hot corner to lock the screen of my Mac, but I always wished there was the equivalent of Windows-L in Windows to do it.
I have no idea when this keyboard shortcut was added, but tapping the CTRL-CMD-Q shortcut will lock your Mac screen. Apparently, if you have a small magic keyboard, then CTRL-Shift-Eject will do the job too. This Stack Exchange Question shows the shortcut wasn’t available in 2015. Users had to resort to all sorts of tricks to lock their screen with the keyboard. An updated answer from 2019 reveals the shortcut, so I guess it’s at least four years old.
Hot corners are great and all, but I’ve had so much trouble making sure the cursor stayed in the corner. I’d watch to make sure my mouse didn’t move, and the screen remained locked. Otherwise, I turn my back, I’m heading out the door and the screen lights up again!
Loads more keyboard shortcuts here if you’re interested in that sort of thing. That page may also explain why something strange happened on your computer while you were typing into the wrong window and changed a Finder setting, for instance.
Have fun getting locked.