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

Under construction. Email me your wish list for improvements.