BUTTON (Function)

is a function which returns the status of the buttons. The parameter  is a numerical value which is rounded down; it may be omitted, the default value is 0. If a number outside the range 0 to 3 (inclusive) is used, the system gives an  error; if a string is used, the system gives a   error; if two parameters are given, the system gives a   error. The values are updated at the beginning of every frame.

(or ) returns the current state of the buttons: a bit being set indicates the button is pressed, the bit being clear indicates the button is released.

behaves like  - for one frame after the button goes from up to down, the bit is set, then the bit is clear for all subsequent frames during the time the button is down, during the time the button is released, and it is set again only when the button goes from up to down again.

is for 'auto-repeat' buttons; for details, see.

is like, except instead of indicating when the button changes from up to down, it indicates when the button is released: when it changes from down to up.

The relationship between buttons and the return value of  is summarized in the following table: