If you decide that you want your application to use function keys, it is highly likely that you will want to be able to determine
exactly which key has been pressed. To do this you need to include the CRT STATUS clause in the Special-Names paragraph of
your program as follows:
special-names.
crt status is key-status.
where:
- key-status
- is a three-byte data item in the Working-Storage Section of your program with the following definition:
01 key-status.
03 key-type pic x.
03 key-code-1 pic 9(2) comp-x.
03 key-code-2 pic 9(2) comp-x.
Whenever an ACCEPT statement is executed,
key-status is set to indicate how the ACCEPT was terminated. The exact usage of the individual fields in
key-status is described later. However, in general they have the following uses:
- key-type
- is how the ACCEPT was terminated. The values returned are as follows :
- "0"
- is a normal termination of the ACCEPT
- "1"
- is termination by a user function key
- "2"
- is termination by an Adis key
- "3"
- is termination by an 8-bit data key
- "4"
- is termination by a 16-bit data key
- "5"
- is termination by a shift key
- "6"
- is termination by a lock key
- "9"
- is termination by a lock key
These different values are described fully later in this section.
- key-code-1
- is the number of the key that terminated the ACCEPT operation. The exact meaning of this number depends on the value returned
in
key-type.
- key-code-2
- if
key-type and
key-code-1 are 0,
key-code-2 contains the raw keyboard code
for the key that terminated the ACCEPT operation. Where a sequence of keystrokes rather than a single key has been configured
to perform a single function, only the code for the first keystroke is returned.
If
key-type is 4,
key-code-2 contains the second byte of the character which caused the ACCEPT operation to terminate.
Otherwise, the contents of
key-code-2 are undefined.