I just noticed ScriptUI.environment.keyboardState in the tools guide and thought I would post an example of how to have a button respond to modifier keys.
Code: Select allvar dlg = new Window( 'dialog', 'Modifer key Button click Example' );
dlg.btnRun = dlg.add('button',undefined,'buttonText');
dlg.btnRun.onClick = function(){
var keyState = ScriptUI.environment.keyboardState;
if(keyState.shiftKey) alert('do shift click');
if(keyState.ctrlKey) alert('do ctl click');
if(keyState.altKey) alert('do alt click');
if(keyState.metaKey) alert('do meta click');
if(!keyState.shiftKey && !keyState.ctrlKey &&
!keyState.altKey && !keyState.metaKey) alert('do standard click');
}
dlg.btnPnl = dlg.add( 'panel', undefined );
dlg.btnPnl.orientation = "row";
dlg.btnPnl.alignment = "right";
dlg.btnPnl.preferredSize [ 80, 80 ]
dlg.btnPnl.okBtn = dlg.btnPnl.add( 'button', undefined, 'Ok', { name:'ok' });
dlg.btnPnl.cancelBtn = dlg.btnPnl.add( 'button', undefined, 'Cancel', { name:'cancel' });
dlg.show();