Database Reference
In-Depth Information
Detecting Keystrokes
Suppose you have a report you show in Preview mode. As a convenience to the people using
the database, you want the up and down arrow keys to jump to the previous and next page re-
spectively (they just can't get the hang of the topic icon). It's a perfect job for an OnLay-
outKeystroke trigger.
NOTE
If you want Ctrl or -key shortcuts for your database, you should use custom menus, not keystroke
triggers. See Custom Menus for details.
When FileMaker calls your script from a keystroke trigger, it remembers which key the per-
son pressed. The script uses an If statement with the Get(TriggerKeystroke) function to
find out what key was pressed. Then the script can take appropriate action based on the value
that's returned. For instance, if the “a” key is pressed, Get(TriggerKeystroke) returns “a”
to the script. If “A” (using the Shift key) is pressed, the script gets a capital “A” instead.
NOTE
If you care about uppercase vs. lowercase in your script, you can use the Exact function. This func-
tion compares two values, and returns True only if they're exactly the same, including case. So in-
stead of this:
If ( Get ( TriggerKeystroke ) = "a"; "Yes"; "No")
You should do this:
If ( Exact ( Get ( TriggerKeystroke ), "a"); "Yes"; "No")
The first example results in “Yes” if the user presses “A” or “a,” while the second gives you “Yes”
only if she types a lowercase “a.”
There are characters you can't type in FileMaker's Specify Calculation window, like an up or
down arrow. But you can use the Code0 function with Get(TriggerKeystroke) to figure
out what key was pressed. Here's the calculation for testing for the up arrow key:
Code ( Get ( TriggerKeystroke ) ) = 29
The numeral 29 is the Unicode code point (or number) for the up arrow key. The codes are
listed in FileMaker's online help (search for “Code”) or right here:
▪ Backspace: 8
Search WWH ::




Custom Search