A newer version of Max is available. Click here to access the latest version of the documentation

numkey Reference

Interpret numbers typed on the keyboard

numkey

Examples

Recognizes all numbers typed in

Arguments

format [float]

Optional

A float argument causes numkey to understand the decimal point and the fractional part of a number, and send out floats instead of ints. (The argument does not, however, set an initial value for numkey. The initial value is always 0.)

Attributes

Common Box Attributes

Messages

bang

Sends the number currently stored in numkey out the left outlet, and resets the stored number to 0.

int

Arguments

ASCII [int]
The number is an ASCII value received from a key or keyup object. When digits are typed on the computer keyboard, numkey recognizes the ASCII values and interprets them as the numbers being typed.

The keys recognized by numkey are the digits 0-9, the Delete (Backspace) key, decimal point (period), Return, and Enter. Digits are combined as a single number and stored in numkey.

clear

Reset the stored number to 0

Output

float

When there is a float argument, numkey understands decimal points and fractional parts of a number, and sends out floats instead of ints.

int

When digits are typed on the computer keyboard, and the ASCII value (from key or keyup) is received in the inlet, the digits are combined as a single number and stored in numkey. The stored number is sent out the right outlet each time a new digit is typed. The Delete key on Macintosh or Backspace key on Windows erases the most recently typed digit, and sends the stored number out the right outlet. The period key acts as a decimal point and causes numkey not to store subsequent digits until a new number is started (unless there is a float argument). Typing the Return or Enter keys on Macintosh or the Enter key on Windows sends the stored number out the left outlet and resets the number stored in numkey to 0, so that a new number can be typed in.

See Also

Name Description
key
keyup
number
Max Basic Tutorial 8: Keyboard and Mouse Input Max Basic Tutorial 8: Keyboard and Mouse Input