Brian Dunning's FileMaker Custom Functions

ModifiersOn ( keys )

Returns whether modifier key-combination pressed.

  Average rating: 4.2 (22 votes) Log in to vote

Eric   Eric - Show more from this author
SJSU
https://community.filemaker.com/people/eric

Share on Facebook Share on Twitter

  Sample input:
ModifiersOn ( "Shift" )

ModifiersOn ( 9 )

ModifiersOn ( "Ctrl-Alt" )

ModifiersOn ( 0 )

ModifiersOn ( "" )
  Sample output:
1 when shift pressed

1 when shift-option pressed

1 when ctrl-alt pressed

0 when any modifier pressed

$ShiftOn
$CapsLockOn
$ControlOn
$AltOn
$CommandOn
when all keys pressed

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

ModifiersOn ( keys ) ©2015 Eric Matthews, San Jose, CA :-)
Returns whether modifier key-combination pressed.

Purpose
Returns 0 (False) if the modifier key or key-combination specified is not pressed
and 1 (True) if the key or key-combination specified is pressed,
or returns a list of variables flagged corresponding to keys pressed.

Parameters
keys - number representing one or more modifier keys and/or a key name, or a combination of key names

Data type returned
number or text

Description
Use this function to test whether a modifier key or specifiec combination of keys are pressed.
Specifying one key will test for that key only.
Valid values to specifiy key:
SHIft, 1;
CAPslock, 2
CONtrol, CTRl, 4
ALT, OPTion, 8
COMmand, 16
A single number can be specified to represent multiple keys. E.g. 31 = All keys pressed.
Or "Shift-Control-Alt" will test whether all three of those keys were pressed in combination.
A number can be specified in combination with names:
"3CtrlAlt" is the same as "Shift-CapsLock-Control-Option"
Also ModifiersOn(0) is True when no modifier keys are pressed, False when any modifier key is pressed.

Adaptions from custom functions ModifierVariables (©2009 Jeffanna Design)
http://briandunning.com/filemaker-custom-functions/detail.php?fn_id=980 :
If keys is empty (e.g. ""), this function "...sets a series of local variables based on which modifier keys are being pressed, e.g.
If the shift key is being pressed, $ShiftOn = 1.
If the command key is not being pressed, $CommandOn = 0."

This function will then also return a list of those variables turned on.
Note: The output of this function with no key specified can be used to specify a key or key-combination for this same function.

Examples
ModifiersOn ( "Shift" ) = 1 when shift pressed
ModifiersOn ( 9 ) = 1 when shift-option pressed
ModifiersOn ( "Ctrl-Alt" ) = 1 when ctrl-alt pressed
ModifiersOn ( 0 ) = 0 when any modifier pressed
ModifiersOn ( "" ) =
$ShiftOn
$CapsLockOn
$ControlOn
$AltOn
$CommandOn
when all keys pressed

 

Comments

Eric   Eric, SJSU
May 31, 2015
Modified 5/31/2015. I changed the alias "CTL" for "control" to "CTRL"
 

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: