Amos Professional Manual  Contents  Index

Using the Keyboard


This Chapter reveals how AMOS Professional exploits the potential of your keyboard.

Checking for a key-press
The keyboard can be used to interact with your routines once they are running. This is vital for any sort of arcade game, adventure gaming or for more practical items such as word processing.

INKEY$
function: check for a key-press
k$=Inkeys$

This function checks to see if a key has been pressed, and reports back its value in a string. For example:

E> Do
    K$=Inkey$
    If K$<>""Then Print "You pressed a key!"
   Loop

Now use the INKEY$ function to move your cursor around the screen, like this:

E> Print "Use your cursor keys"
   Do
    K$=Inkey$
    If K$<>""Then Print K$;
   Loop

The INKEY$ function does not wait for you to input anything from the keyboard, so if a character is not entered an empty string is returned. INKEY$ can only register a key-press from one of the keys that carries its own Ascii code, and the Ascii code numbers that represent the characters which can be printed on the screen are explained in Chapter 5.2.

It has also been explained that certain keys like [Help] and the function keys [Fl] to [F10] do not carry as Ascii code at all, and if INKEY$ detects that this type of key has been pressed, a character with a value of zero will be returned. When this happens, the internal "scan codes" of these keys can be found.

SCANCODE
function: return the scancode of a key entered with INKEY$
s=Scancode

SCANCODE returns the internal scan code of a key that has already been entered using the INKEY$ function. The next example may be tested by pressing the function keys, [Del] and [Help]. To interrupt the example, press [Ctrl]+[C].
Back    Next
10.01.01