ModKey

part of wslib


a class for testing modifier keys from strings given by mouseActions and keyActions.


Tested on a PBG4. Please tell me if it doesn't work for your machine

info@woutersnoei.nl


Based on empirical testing...


Creation


ModKey( args )

if the first arg is a number, this will be converted inside to a list of modKeys.

If the args are Symbols, they will be stored inside.


ModKey( 1179648 );  // -> ModKey( \cmd, \shift )


(

w = SCWindow().front;

a = SCUserView(w, 400@400 );

a.mouseDownAction = { |v, x, y, m| ModKey( m ).postln; };

) // click inside the window with and without modifier keys pressed ( shift, alt, ctrl etc.)



Testing


includes ( modNames, mode )

modNames can be a single or list of modifier names (Symbols)


known modnames:

cmd, ctrl, capslock, fn, shift, alt


mode is also a symbol which can be:


all (default) should include all given modNames

any should include any of the modnames

only should include only all the given modnames, and no others

onlyAny should include only one or more of the given modnames and no others

one should include one of the given modnames, but not more. May include others (not given)

onlyOne should include only one of the given modnames and nothing else



m = ModKey( \shift, \cmd );


m.includes( [ \shift, \cmd, \alt ] );   // -> false

m.includes( [ \shift, \cmd, \alt ], \any ); // -> true

m.includes( [ \shift, \alt ], \one );  // -> true

m.includes( [ \shift ], \onlyOne ); // -> false


shift, capslock, ctrl, cmd, alt, fn

shortcuts for all common modifiers. Takes mode as argument


m.shift;          // -> true

m.shift( \only ); // -> false


cl, option, apple, command, function

alternate names for above


m.apple; // -> true (apple == cmd)


shiftCapslock ( mode, mode2 ), shiftCl ( mode, mode2 )


mode2 equals mode in the above methods

mode  can be \xor (default) and \or

xor : shift or capslock is pressed, not both

or : shift and/or capslock is pressed