The BUTTON command returns the press state of all buttons at the moment it was called. What kind of press it was depends on the number you include as the parameter, however, you will probably only use BUTTON() and BUTTON(2), where the empty one returns held down buttons and the one with a 2 returns just pressed buttons. You can also assign BUTTON's return value to a variable for convenience.