Skip to main content
Zhiqing_Li
Known Participant
November 2, 2012
Question

how to use "Esc" key to call a function in scripting

  • November 2, 2012
  • 1 reply
  • 748 views

I mean when I'm executing a script,if I want break a loop, I can just press the "Esc" key.I think this is very handly.But I also want to call a function when "Esc" is pressed,is this possible, and how can I do this?

This topic has been closed for replies.

1 reply

Alan_AEDScripts
Inspiring
November 2, 2012

Taken from Peter Kahrel's UI guide.

http://www.kahrel.plus.com/indesign/scriptui-2-0.pdf

So escape could be captured by if(myWindow.show()==2){do stuff }?

the user clicks OK (which in this script corresponds to pressing Enter) or they can click

Cancel (which is the equivalent of pressing Escape). The window's behaviour is

this: if the user presses OK, the line myWindow.show ( ) returns 1, if they press

Esc, that line returns 2. We capture this as follows:

if (myWindow.show () == 1)

var myName = myText.text;

else

exit ();