Skip to main content
Inspiring
May 30, 2021
Answered

Keyboard shortcut to execute specific function from script

  • May 30, 2021
  • 1 reply
  • 10825 views

I work with custom Photoshop scripts and keyboard shortcuts.

Is it possible to have a keyboard shortcut execute a specific function within a script?

and, another keyboard shortcut executes another function in the same script?

 

For example?

Citrus.jsx

  • function pomelos(){}
  • function lemons(){}
  • function oranges(){}

 

Keyboard F1 executes the function Pomelos

Keyboard F2 executes the function Lemons

Keyboard F3 executes the function Oranges

 

 

 

This topic has been closed for replies.
Correct answer r-bin

Got it, I realized it is possible to add more than one keyboard shortcut per script in Photoshop.

Each function key alerts the function key number followed by Error 21.

 

The Adobe UXP is the new Unified Extensibility Platform to build panels.

To make it user-friendly the button panel should stay docked to make it accessible.


[Profanity removed]

Remove the first test alert() and refresh() from the script.

1 reply

Kukurykus
Legend
May 30, 2021

Assiang F1 key to the script, basicly for pomelos function. When you want to trigger lemons then during refreshment change your finger from F1 key to F2. Similary if you want to initiate oranges, switch to F3.

 

refresh()

function pomelos() {alert(callee.name)}
function lemons() {alert(callee.name)}
function oranges() {alert(callee.name)}

({1: pomelos, 2: lemons, 3: oranges})[ScriptUI.environment.keyboardState.keyName[1]]()

 

Inspiring
May 31, 2021

I try the citrus.jsx script in Photoshop CC 2021 and get error 21 when I press the F1 key in a mac.

Then I get several erro 24 dialogs when I press F1 ket for one sec and then switch to F2 key.

What do these errors mean?

 

 

Inspiring
May 31, 2021
quote

The Adobe UXP is the new Unified Extensibility Platform to build panels.

To make it user-friendly the button panel should stay docked to make it accessible.


By @Polycontrast

 

Can you provide a sample code for such a panel? How does it work, how does it run? Are they text files like jsx files?


Awesome! Thank you all. I am able to call specific functions within the same script using separate keyboard shortcuts in a mac osx without errors.

F1 calls the function pomelos

F2 calls the function lemons

F3 calls the function  oranges

 

I don't have any code to share about UXP panels since I am just learning about this new framework and have not built a plugin yet. However, I can share a link that covers how to get started UXP for Adobe Photoshop