Myself and several other InDesign developers would once again like to ask for keyboard shortcut support. I brought this up in the last developer office hours, and I’d like to provide some more information and discussion.
Keyboard shortcuts are mentioned in the Known Issues section in the UXP documentation, so hopefully Adobe recognizes that this is a long-standing issue with InDesign scripting that needs a better solution.
I’d like to propose that UXP plug-ins could be listed inside of a new or existing Product Area within the Keyboard Shortcuts menu in InDesign (Edit > Keyboard Shortcuts...
). The plug-in would define commands that can be bound to a key in the manifest.json file, or perhaps all entrypoints
with type command
could automatically be listed in the Plug-ins Product Area.
This would allow the user to update or remove keybindings themselves, using a dialog and functionality that already exists within the application. This would also ensure that there is never overlap between keybindings.
For context, I’m re-building a tool for typesetting text into an InDesign file, and allowing the user to navigate the script with keypresses would be transformative:
In a previous iteration of this tool in ExtendScript, I used the workaround of asking the user to install additional helper scripts to navigate the script, and have them assign those scripts to keys in the Keyboard Shortcuts menu. That’s where this idea came from, since it worked really well even if installation was tedious.
4 Likes
Yes please, we need the ability to assign keyboard shortcuts to UXP based plug-ins.
I too have asked during an Office Hours (I think Adobe InDesign specific back in July of 2023) for Keyboard shortcut support with UXP plug-ins.
I too, with ExtendScript, used auxiliary helper scripts that could be assigned keyboard shortcut scripts. I’ve not looked at if this is a possibility or not with UXP.
jsw
1 Like
The best workaround I’ve found so far for UXP is to have the plug-in create a scriptMenuAction
and attach an afterInvoke
event listener to it, e.g.:
var menuItem = app.scriptMenuActions.item("menuItemName");
if (!menuItem.isValid) {
menuItem = app.scriptMenuActions.add("menuItemName");
}
var handleEvent = function(event) {
console.log(event);
}
menuItem.addEventListener("afterInvoke", handleEvent);
And then, ask the user to install an ExtendScript script, with contents:
var menuItem = app.scriptMenuActions.item("menuItemName");
if (menuItem.isValid) menuItem.invoke();
And then ask the user to set the script to a keyboard shortcut.
The plug-in would have to check periodically to make sure the scriptMenuAction
still exists.
This is incredibly ridiculous, but it’s the best I’ve come up with so far. Really hoping someone chimes in with a better solution.
@salinsley Yeah, that is similar to what I did with ExtendScript. And it matches my plan to do with UXP. The only improvement I can offer is that you should be able to write the ExtendScript (via your UXP Plug-in) to the User’s scripts folder so they don’t have to manually install it.