button.onClick = function() { var keyboardState = ScriptUI.environment.keyboardState; if (keyboardState.shift) { alert('shift'); } // etc };