EDIT: So I think it would be best if shift was an unsigned long and the if condition should read: if( shift == 0xFFFFFFFF ){
To sum it up, it acts like a shift register that shifts in zeros but will add 1 anytime the button stays low. So whenever it bounces up there will be a zero that has to be shifted all the way through.
This function bit shifts the variable 'shift' every loop. If the button is LOW like it is supposed to be, it will add 1 to fill that shifted bit in, otherwise there is a zero there that will be shifted through. The function just waits until every bit is a 1. In other words, the BUTTON is constantly LOW.
That makes sense, I guess. But how is the function used? It takes no arguments, and returns nothing. The only global variable always has the same value when the function does end. Why is that variable global, anyway?