EPOC   SDK Home Glossary   Previous Next Up

KEYKMOD


Contents


KEY — Gets the last key pressed as a character code

Usage:      k%=KEY

Returns the character code of the key last pressed, if there has been a keypress since the last use of the keyboard by INPUT, EDIT, GET, GET$, KEY, KEY$, MENU and DIALOG.

If no key has been pressed, zero is returned.

See Character codes for a list of special key codes. You can use KMOD to check whether modifier keys (Shift, Ctrl, Fn, and Caps Lock) were used.

This command does not wait for a key to be pressed, unlike GET.


KEY$ — Gets the last key pressed as a string

Usage:      k$=KEY$

Returns the last key pressed as a string, if there has been a keypress since the last use of the keyboard by INPUT, EDIT, GET, GET$, KEY, KEY$, MENU and DIALOG.

If no key has been pressed, a null string ("") is returned.

See Character codes for a list of special key codes. You can use KMOD to check whether modifier keys (Shift, Ctrl, Fn, and Caps Lock) were used.

This command does not wait for a key to be pressed, unlike GET$.


KEYA — Reads the keyboard asynchronously

Usage:      err%=KEYA(var stat%,var key%(1))

This is an asynchronous keyboard read function.

See Scanning the keyboard directly for details.

Cancel with KEYC.


KEYC — Cancels a KEYA

Usage:      err%=KEYC(var stat%)

Cancels the previously called KEYA function with status stat%. Note that KEYC consumes the signal (unlike IOCANCEL), so IOWAITSTAT should not be used after KEYC.

See Scanning the keyboard directly for details.


KILLMARK — Removes a bookmark

Usage:      KILLMARK b%

Removes the bookmark b%, which has previously been returned by BOOKMARK, from the current view of a database.

See BOOKMARK, GOTOMARK.


KMOD — Gets the state of the modifier keys

Usage:      k%=KMOD

Returns a code representing the state of the modifier keys (whether they were pressed or not) at the time of the last keyboard access, such as a KEY function. The modifiers have these codes:

KKmodShift%

2

Shift down.

KKmodControl%

4

Ctrl down.

KKmodCaps%

16

Caps lock on.

KKmodFn%

32

Fn down.

These constants are supplied in Const.oph.

If there was no modifier, the function returns 0. If a combination of modifiers was pressed, the sum of their codes is returned — for example 20 is returned if Ctrl (4) was held down and Caps lock (16) was on.

Always use immediately after a KEY/KEY$/GET/GET$ statement.

The value returned by KMOD has one binary bit set for each modifier, as shown above. By using the logical operator AND on the value returned by KMOD you can check which of the bits are set, in order to see which modifier keys were held down. For more details on AND, see Operators and logical expressions.

Example:

    PROC modifier:
          LOCAL k%,mod%
          PRINT "Press a key" :k%=GET
          CLS :mod%=KMOD
          PRINT "Key code",k%,"with"
          IF mod%=0
                PRINT "no modifier"
          ENDIF
          IF mod% AND KModShift%
                PRINT "Shift down"
          ENDIF
          IF mod% AND KModControl%
                PRINT "Control down"
          ENDIF
          IF mod% AND KModCaps%
                PRINT "Caps Lock on"
          ENDIF
          IF mod% AND KModFn%
                PRINT "Fn down"
          ENDIF
    ENDP
EPOC       SDK Home Glossary   Previous Next Up