If you look at all the button constants (#A, #B,#UP, etc) they are powers of 2, a consequence of this binary math. So as stated by others when you use == you check for equal to which matches a specific state for all the buttons not just one. if button() == (#A + #B) for example would only be true if the A and B buttons are pressed and nothing else. You use AND to check buttons individually.