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. 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.