The PEN command is a BASIC v7 function, used for reading the status of the light pen.

The numeric expression must be 0-4. Using any other number generates an ?ILLEGAL QUANTITY ERROR.

The PEN command returns a value depending upon the value that is supplied:

0: The horizontal position of the light pen.

1: The vertical position of the light pen. The first two values refer to the entire screen, not just the area that is accessible through drawing, leading to odd numerical ranges- the C128 system guide states, "The x position is given as a number, ranging from approximately 60 to 320, while the y position can be any number from 50 to 250."

2: The text column position on the 80-column screen

3: The text row position on the 80-column screen. The text position outputs only register when the pen is used on the 80-column screen; on the 40-column screen, they do not update, returning the last-returned value from the 80-column screen.