Skip to main content
Inspiring
August 11, 2020
Question

Photoshop CS6 Mac: extendscript addEventListener keydown?

  • August 11, 2020
  • 0 replies
  • 239 views

Hello,

 

Is there any way to link some keyboard shortcuts to a dialog window in Photoshop 13 (CS6) on Mac?

I mean a "direct" shortcut, like the ones for the Tool palette for example, and not a command-key shortcut (like the menus ones).

I tried this:

var w = new Window ("dialog");
var testText = w.add('statictext', [0,0,400,70], 'Press any key...\n\n(Escape to close this window.)', {multiline: true, justify: "left"});
w.addEventListener ("keydown", function (kd) {pressed (kd)}); // or false ?

function pressed (k) {
testText.text = k.keyName + '---' + k.keyIdentifier;
//alert(k.keyName + '---' + k.keyIdentifier);
}

w.show();

 

But when I hit a key, I only have a beep. It seems the modal dialog doesn't allow any action.

I also tried to listen a button instead a the whole window, like this:

var w = new Window ("dialog");
var testText = w.add('statictext', [0,0,400,70], 'Press any key...\n\n(Escape to close this window.)', {multiline: true, justify: "left"});
var testBtn = w.add("button", undefined, "T", {name: "test"});
testBtn.addEventListener ("keydown", function (kd) {pressed (kd)}); // or false ?

function pressed (k) {
testText.text = k.keyName + '---' + k.keyIdentifier;
//alert(k.keyName + '---' + k.keyIdentifier);
}

w.show();

 

If I hit a key as soon as the window is shown, I only have beep. But if I first click the defined button, staticText is updated when I hit a key (but I also have beeps).

 

I suppose the problem is due to the "dialog" window: maybe It will work fine with a "palette" window, but palettes are not working on Mac.

 

Thank you for your help.

This topic has been closed for replies.