BTRIG (Function)

is a system function that takes no parameters and indicates what buttons have been recently pressed.

The value returned by  is recalculated at the beginning of every "frame", that is, every 1/60th of a second (and for the duration of the frame, it does not change). If, during the previous frame, a button had changed from being up to being down, a bit is set in the value of, otherwise (if the button had been down all during the previous frame, or if it had remained up, or if it had changed from being down to being up) the bit is clear.

is usually used in conjunction with ; e.g., without   between successive calls to , both calls may occur in the same frame, both indicating that a button has been recently pressed, and the program may behave as if the button had been pressed twice when it had actually only been pressed once.

The bit masks are the same as for :