On my scriptUI panel, I have a button. How can I detect whether the user is holding the shift
key when they click on the button?
Asked
Active
Viewed 1,083 times
3
1 Answers
5
You can add an eventListener to your button.
var win = new Window ("dialog");
win.aButton = win.add ("button", undefined, "Button");
win.aButton.addEventListener ("click", function (k) {
if (k.shiftKey) {
alert("foo");
}else{
alert("bah");
}
});
win.show ();

fabianmoronzirfas
- 4,091
- 4
- 24
- 41
-
That, indeed, works, but I need to attach the listener to a button (I have several buttons; each needs a listener of its own). If I do: `whatbutton.onClick = function(k){ }` it all works until I do something with `k`. – bgmCoder May 08 '13 at 19:33
-
Never mind; I used your `addEventListener` instead of my `onClick` and it worked like a charm. Thank you! – bgmCoder May 08 '13 at 19:38
-
1Do you know Peter Kahrels Script UI guide? http://www.kahrel.plus.com/indesign/scriptui.html it's my favorite UI development resource – fabianmoronzirfas May 09 '13 at 05:43
-
Yes, I've been there. There is also jongware's guide: http://jongware.mit.edu/idcs5/ – bgmCoder May 09 '13 at 14:14