I'm going to try to explain what I'm experiencing as clearly as I can (but it's a bit complicated).
I use Mac computers, and frequently change the app I'm working on with the keyboard shortcut "Cmd-Tab". If I am doing something in Photoshop (currently using v23.2.0, but it's been happening for quite some time), switch apps, and then return to Photoshop and try to execute a command using a keyboard shortcut (such as using Cmd-B to get the brush tool), the app will issue an error sound and nothing will happen. It's only when I click inside the Photoshop app window that keyboard commands become available. No other app that I can think of demonstrates this behaviour, not even other Adobe apps (e.g., I can switch into Lightroom this way, and without clicking anywhere I can hit the D key to change to Develop mode, for instance). Is this a "feature" of the Mac operating system, or is there something I can do to fix this? It's pretty annoying.