Skip to main content
Inspiring
December 10, 2019
Question

app.addEventListener("keydown" ... fails. Is there a way?

  • December 10, 2019
  • 1 reply
  • 2032 views
app.addEventListener("keydown", function (kd) { pressed(kd) });
app.activeDocument.addEventListener("keydown", function (kd) { pressed(kd) });
 
 
both fail -- "keydown" is not a recognized event type
 
Is there a way to add a keydown event listener at the app level?
(Trying to write a script that will process keystrokes sent by an external app...)
This topic has been closed for replies.

1 reply

Community Expert
December 12, 2019

Hi akiva_atwood,

what is the external app?

 

As far as I know "keydown" or "keyup" as event type can only be added successfully to event listeners with ScriptUI window elements like EditText in InDesign. See Marc Autret's answer in this thread:

 

Where is there a list of InDesign Event types?
Dick_Kain, Jan 05, 2017

https://community.adobe.com/t5/indesign/where-is-there-a-list-of-indesign-event-types/m-p/8851632

 

Regards,
Uwe Laubender

( ACP )

 

 

Inspiring
December 12, 2019

Hi Uwe

Streamdeck -- it's a remote conrols hardware device.

It can send text strings to any app.

(It can also communicate via HTTP -- but I haven't managed to get ID to work as a HTTP Server (I'm on a mac))

I want to write a monitor script that looks for certain text strings coming in (for example "CSBold" and then assigns the "Bold" character style)

This avoids needing to set up keyboard shortcuts in each doc

Inspiring
December 13, 2019

Apparently keydown events only work with dialog windows -- if I change my code to make it a palette it doesn't catch the event even if the palette has the focus...