Login
Plus/4 EncyclopediaFirstBackNextLast

GETKEY Statement
Category
Reference/Commodore Basic V3.5

Topic
GETKEY variable list

The GETKEY statement is used to get data from the keyboard one character at a time. When it is executed, program execution is paused until a key is pressed.

GETKEY is followed by a variable name, which is fed with the returned character. This is usually a string variable. If a numeric variable is used and a non-numeric key is pressed, a ?TYPE MISMATCH ERROR occurs. Additional variables may be added, seperated by commas. GETKEY will wait until a key is pressed for each variable in the list.

Because GETKEY pauses a program until a key is pressed, it is not suitable for programs running continuously while awaiting key presses (such as action games). To do this, use the GET statement instead.

Note that GETKEY can also be written as GET KEY.

This statement can only be used within a program. If it is used in direct mode, an ?ILLEGAL DIRECT ERROR will occur.

Examples
10 GETKEY A$ Program waits until a key is pressed, whose character is entered into variable A$
20 GETKEY B$,C$,D$ Program waits until three keys are pressed, one for each variable.

Abbreviation
G SHIFT+E K SHIFT+E



Copyright © Plus/4 World Team, 2001-2024