Clicking any button on any UXP panel inactivates keyboard shortcuts for tools and brush sizes

The topic title pretty much says it all. Whenever I click on a UXP panel button, I can no longer use keyboard shortcuts to choose a Photoshop tool or adjust brush size with the bracket keys. After using Photoshop without clicking on a UXP panel, these keyboard shortcuts return. It is incredibly frustrating.

ExtendScript had ‘app.bringToFront()’ function as a way to restore focus to the app to prevent this from happening.

Is there something similar in UXP that works?

I tried:

const app = require('photoshop').app; await app.bringToFront();

But that doesn’t restore the keyboard shortcuts.

NOTE: Not all keyboard shortcuts are inactivated by UXP panels. CTRL+K still works to open the Preferences, and once I do that, all the tool and brush size keyboard shortcuts are restored.

This seems like a major shortcoming of UXP panels. It makes it look like Photoshop doesn’t work right or is all of a sudden buggy.

I don’t think keyboard shortcuts are supported in UXP yet. I could be wrong… (@kerrishotts?)

This is a bug in the current release; it’s being addressed. I’m not sure it’ll make it in our next update or not, though.

The issue is that the UXP panel now has focus, which means that keyboard events are being sent to the panel, and not to Ps. The user can click elsewhere in Ps (on something that takes focus, like an input) to take focus back, which will return PS’s keyboard shortcuts. Otherwise, an application switch always returns focus.

As to why bringToFront isn’t working… I’m not sure. When I run the equivalent batchPlay command, it returns an error with Could not complete your request because a command was not available., which probably explains why your call to app.bringToFront appears to do nothing.

@Barkin or @heewoo might have more insights here.

This does mean that, right now, I don’t know of any way to programmatically return keyboard shortcuts to the user.

Hey @kerrishotts is there any update on when this might be resolved? I appear to have run into the same issue with shortcuts to the tools not working. Many Thanks!

Hate to keep beating the drum on this, but is there any chance the app.bringToFront API could be repaired even if the overall focus issue isn’t resolved. I’d be happy to add this API at the end of all my functions to restore focus to Ps. I understand that the focus issue is complex and an overarching solution might not be available until PS 2022 is released in October (not sure where I read that), but fixing the API could alleviate the the frustration of this issue in many circumstances. app.bringToFront worked fine in JSX, so there must be some way to call it in UXP.

Any news about app.bringToFront();?

the number of functions in my plugin is 350. All of them block hotkeys for the user. Users think this is a bug of my plugin, which in turn affects my reputation.

I found one way to get the focus back programmatically. I launch small uxp dialog window and using the function:


After 100 milliseconds the focus goes back to Photoshop and hotkeys start to work correctly.
The disadvantage of this method is that when using each command, we see an animation of opening and closing an empty window.


Maybe there is some other workaround for returning focus?
When is implementation planned app.bringToFront();?

That does work, @Alexandr_Stroganov. You certainly got further on this than I did. But the pop-up “X” is annoying also. Setting the dialog modal’s height and width to 0px doesn’t eliminate it either.

I think it is possible to enable this method as an additional setting in your plugin. If the user wants, then he can turn it on with an explanatory message why it is needed.

I’m currently testing this. If there is a second monitor, then you can move there too. I tested in the corner, also discreetly. :upside_down_face:

But maybe there is a parameter for the modal that can remove the closing element.

Do you know where I can see a list of all the properties of a uxp modal window?

Based on the feedback I’ve received from people using UXP plugins, NOBODY would turn this off. The frustration factor with inactive keyboard shortcuts is incredibly high.

I don’t know of a list of properties for the UXP modal, but someone reading this thread might.

Are you able to programmatically move the “X” button of the modal to other than the center of the Photoshop workspace?

I have tried putting the dialog within a <div> of height and width of 0px, but that doesn’t hide the dialog. Didn’t figure that would work, but trying everything I can think of.

I was able to move the window out of the center. With one button, you launch the window without closing. Then drag and drop where necessary. And in all functions, you already prescribe opening and closing.

Also, the panel height must be at least 1 pixel, otherwise, it won’t work. But the disadvantage of this method is that after closing Photoshop, this operation will have to be repeated.

But! @AnthonyK have great news for you :sunglasses:. I found an INVISIBLE way that returns focus after researching the effects of various Photoshop commands.

    kcanDispatchWhileModal: true,
    _isCommand: false

But by default, this function is already “Automatic”. This code just sets the same value, but it returns the focus to photoshop and the hotkeys start working! It’s also great news that this command leaves no trace in history.

Yes, we have a small problem that if the user has this option set to “always show”, then we will disable it. But to be honest, this is the first time I saw that there is such an additional panel. That is, the likelihood of this is extremely small, which makes this method ideal for returning focus.

But even in this case, a checkbox option can be made for the user, which will change one method to another, if he needs this additional panel. We just change "commandID": 1208 to "commandID": 1209


I’ve also discovered various other commands that return focus, but they all have a significant impact on the user interface.

That’s absolutely amazing, @Alexandr_Stroganov. Intial tests shows this works as advertised. Not at all familiar with this .core.performMenuCommand code, but it looks to be a promising workaround until app.bringToFront works or the whole focus issue gets resolved.

1 Like

the only thing left to do is to implement it in all places of the plugin.

cheers! :slightly_smiling_face:

I wonder if there is a way to get the current “Animation Options” value from Photoshop with a getter. That way it could be used to run the focus-returning batchPlay regardless of how the user has it set. I didn’t see it in the inspector “application” read-out from Alchemist. Will tag @Jarda to see if he has any thoughts. Or maybe someone from Adobe could provide additional info on this.

I have tested this “Animation Panel” call on PC and it works well ! However, I tested the exact same lines on Mac and I’m afraid it’s not doing anything… arrghh…

That’s very unfortunate, though not entirely surprising, I suppose. I’ve had to code workarounds for Macs several times. What about using setTimeout() to see if that helps?

I’ll try that in a few hours and report

Isn’t there some hidden/optional property for layer?

Can you please try?



    kcanDispatchWhileModal: true,

    _isCommand: false


There is animationProtection property in layer.

@Alexandr_Stroganov , 5933 makes all windows tile vertically, and focus still belongs to the panel…