User-defined Keys
Your Computer, October 1983

John Burton,
Rugby,
Warwickshire.

This program for the 48K Spectrum provides 33 user-defined function
keys which are used in a simliar way to those on the BBC Micro.

Beacause there are no unused keys on the Spectrum keyboard, a new
shift key is used to access them. The Space key is used in the same
way as the two existing shift keys. It, and any other key pressed
together will produce the required line in the edit/input area at the
bottom of the screen. For example, if the H key was programmed with:

	BORDER 7: PAPER 7: INK 0: CLS

Pressing Space and H together will produce that line when the next key
is pressed.

Programming the keys is usually only done when the program to set up the
machine code is run, but could be done using Poke also.

After program 1 is entered, key definitions should be entered from line
3000 onwards. This should have the code for each keyword or letter or
symbol with the last one being zero. For example, the line shown above
would be:

	3000 DATA 231,55,58,218,55,58,217,48,0

where 231 is the code for border, 55 the code for 7, and 58 the code for :
and so on.

The first Data line after 3000 will define key H, the second will define Y
and the third 6. The sequence is:

	H Y 6 5 T I G V (N) J U 7 4 R F C (M)

and so on.

The letters in brackets cannot be programmed but must still be given the
code 0 in the data lines.

The codes are put in the area of memory from 6032 on with each key having
32 bytes.

The machine code uses interrupts and so cannot be used with another program
that does also. Examples of key definitions:

	Key H : LOAD "": RUN
	Key Y : PLOT 0,0: DRAW 255,0: DRAW 0,175: DRAW -255,0: DRAW 0,-175
	Key 6 : Not used
	Key 5 : Print 0;
	Key T : PLOT 55,27: DRAW 50,50,105*PI
	Key 6 : RANDOMISE 0

The data for these lines are:

[see lines 3000 - 3004 in BASIC listing]

To use the program:

1. Type in program one
2. Type in key definitions from line 3000
3. RUN the program
4. Type RANDOMISE USR 65122

Step 4 should be used to re-activate the interrupts whenever New is used.

The program should be saved to tape after step 2 with

	SAVE "USER KEYS"

Once all the steps have been followed, the program and key definitions can
be saved with:

	SAVE "USER CODE" CODE 60000,5535

To load back type:

	1. Clear 59999
	2. LOAD "USER CODE" CODE
	3. RANDOMISE USR 65122