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.