Amos Professional Manual  Contents  Index

Using the Keyboard


KEY SHIFT
function: test the status of control keys
bitmap=Key Shift

KEY SHIFT is used to report the current status of those keys which cannot be detected by either INKEY$ or SCANCODE because they do not carry the relevant codes. These "control keys can kb tested individually, or a test can be set up for any combination of such keys pressed together. A single call to the KEY SHIFT function can test for all eventualities, by examining a bit map in the following format

:
Bit    Key Tested       Notes
0      left [Shift]     Only one [Shift] key can be tested at a time
1      right [Shift]    Only one [Shift] key can be tested at a time
2      [Caps Lock]      Either ON or OFF
3      [Ctrl]
4      left [Alt]
5      right [Alt]
6      left [Amiga]     This is the [Commodore] key on some keyboards
7      right [Amiga]

If the report reveals that a bit is set to 1, then the associated key has been held down by the user, otherwise a 0 is given. Here is a practical example:

E> Centre "Please press some Control keys"
   Curs Off
   Do
    Locate 14,4: Print Bin$(Key Shift,8)
   Loop

These keys can also be used when setting up macro definitions, using the SCAN$ and KEY$ functions, and this is explained below.

CLEAR KEY
instruction: re-set the keyboard buffer
Clear Key

When an appropriate character is entered from the keyboard, its Ascii code is placed in an area of memory called the keyboard buffer. This buffer is then examined by the INKEY$ function in order to report on key presses. CLEAR KEY completely erases this buffer and re-sets the keyboard, making it a very useful command at the beginning of a program when the keyboard buffer may be filled with unwanted information. CLEAR KEY can also be called immediately before a WAIT KEY command, to make sure that the program waits for a fresh key-press before proceeding.

Back    Next
10.01.03