MatchKeys

(Engine-Level Function)

Description: Returns true if the specified keyboard keys have been pressed in the sequence given.
Returns: Boolean
Usage: Steady State only.
Function Groups: Keyboard
Related to: MakeBuff | KeyCount |Keys
Format: MatchKeys(Enable, Keys)
Parameters:  
Enable

Required. Any numeric expression that enables the function. Testing of keyboard input is enabled when this parameter is true (i.e. not 0). If it is 0 (false), then the function's value is false.

In addition, the Enable parameter controls the type of comparison done. If the Enable is 1, a case-sensitive match is made. If the Enable is 2, then the match is not case-sensitive.

(Any non-zero value other than 2 will cause a case-sensitive match. The use of 1 and 2 is recommended for clarity.)

Keys

Required. A text expression giving the key sequence to watch for. The case of individual letters may be significant, depending on the Enable parameter.

To generate extended keys that are not already available as constants defined in the system layer, use MakeBuff to turn the character code(s) into a text expression. For example:

    PageUp    = Concat(MakeBuff(1, 253), MakeBuff(1, 0x49));
    F2        = Concat(MakeBuff(1,253), MakeBuff(1,60));
    F3        = Concat(MakeBuff(1,253), MakeBuff(1,61));
    CtrlZKey  = MakeBuff(1, 26);
Comments:

This function should be used in a window or page module to monitor key strokes.

The Enable parameter is a status expression controlling the comparison. The comparison starts after the Enable becomes true. If the Enable becomes false, the function's value becomes false and the comparison starts at the beginning of the Keys string again after the Enable becomes true. This feature is useful for resetting the MatchKeys function after an action using the function's result has been performed.
The MatchKeys function is also reset automatically when it occurs in an action trigger that becomes true.
The function's result is automatically set to 0 (false) when the state containing the function is entered. After the function becomes true, it remains true as long as the state does not change and the Enable remains true.
Any key sequence may be used for the Keys parameters including the function keys. Note that the MatchKeys function is case sensitive (upper and lower case letters are treated as different characters) when the Enable is an odd number. Often only one key is included in the Keys string. Several keys may be used in the Keys string and function as a password. The keys typed are not displayed on the screen by this function. Several MatchKeys functions may be active at any time, each comparing the keyboard input against their own Keys parameter.

If watching for function keys, you are advised not to override the behavior of F1.

Example:

If MatchKeys(2,"Y");
[
  ...
]

When the letter "Y" is typed on the keyboard, regardless of case, the action will trigger, execute its script, and reset the MatchKeys function to wait until "Y" is typed again.

ASCII Constants

Latching and Resetting Functions