Brian Dunning's FileMaker Custom Functions

KeysDown ( theModifierKeys ; ignoreCapsLock )

User friendly version of Get ( ActiveModifierKeys )

  Average rating: 4.1 (37 votes) Log in to vote

Peter Wagemans   Peter Wagemans - Show more from this author
Lesterius
https://www.lesterius.com

Share on Facebook Share on Twitter

  Sample input:
KeysDown ( "shift-ctrl" ; True )
KeysDown ( "ctrl-shift-alt" ; False )
KeysDown ( "ctrl-capslock" ; False )
  Sample output:
True (1) if ctrl and shift key are down, caps-lock is ignored
True if ctrl option/alt and shift are down, caps-lock should be off
True if ctrl key is down, AND caps-lock is on

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

The Get(ActiveModifierKeys) function returns a number that represents the keyboard modifier keys. When converted to binary, it becomes clear how this number is constructed.
0 0 1 0 1
| | | | |
| | | | Shift
| | | Caps Lock
| | Ctrl
| Alt/Option
Apple Command Key
The custom function tests for each bit, each time comparing it with the presence of the modifier key in "theModifierKeys" (using XOR). All tests are put together using AND, so if one fails, all fail.
The Caps Lock test is only performed when ignoreCapsLock is False.
This custom function is much clearer to read than e.g.:
Get ( ActiveModifierKeys ) = 27
I preferr KeysDown ( "alt-shift-command-capslock" ; True )

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: