Yes, a method covered in any good treatment of software debouncing.
Key is not doing the shifting too frequently. I've seen examples that work only because there is some inherent limit to how fast loop is looping. Here of course you allow for that.
One disadvantage is that it is not (or is it?) a library that one can just tell another to install and use.
I have no trouble picking out the relevant parts and repurposing them, but doing might be more trouble for someone trying to make eight buttons turn eight relays on and off.
If I was going to make someone also understand debouncing, I would start with simpler software that builds on things we might hope they already know, or at least know they don't know yet.
a7