119 25 Programming the red user defined keys At the top of the keyboard is a group of special red keys which are called user defined keys . Instead of producing a fixed character the user can ‘define’ these keys to generate any character or string of characters that is required. For example, to set up key f1 so that it produces the word PRINT every time it is pressed you can type To set key f2 to produce the word DATA you enter *KEY 1 PRINT RETURN *KEY 2 DATA RETURN If you want to enter more than one word into a user defined key then you can enclose the words in quotes *KEY 3 "IF X=" RETURN though quote marks are not necessary.
When you are developing programs it is very useful to have one of the keys set up to change to MODE 7 and then LIST the program automatically. If you were typing in the commands MODE 7 and LIST you would normally follow each with a RETURN , and you have to include something equivalent to pressing the RETURN key when you set the key up. In fact to set up key f0 you enter this: *KEY 0 MODE 7 |M LIST |M The two characters | and M together are understood to mean the same thing as pressing the RETURN key. In fact the | in front of any letter makes the computer generate a control character.
You may remember that to enter ‘paging mode’, where the computer stops at the bottom of every page, you can type CTRL N . That instruction can be added to the key f0 definition as well, if you wish. *KEY 0 MODE 7 |M |N LIST |M It is important to remember than any *KEY definition must be the last statement on a line because once the computer finds a * at the start of a statement it passes the rest of the line to the Machine Operating System and not to BASIC. The Machine Operating System does not understand : which BASIC would understand as a multiple statement separator. The same thing