I struggle with deleting emails from Gmail via keyboard. Every mail app I used always allowed to use the ‘delete’ key, but not Gmail. It defaults to ‘#’ which just is not intuitive. I tried customizing the keyboard short cut via Gmail’s settings, but you can’t assign the ‘delete’ or the ‘backspace’ key to the shortcut.
So, I tried it with KM. A simple macro that when in Chrome triggers the ‘#’ key when pressing the ‘delete’ key. Pretty straight forward, however, that doesn’t work when editing emails or searching emails. While using another key works, I haven’t quite given up on using the delete key.
My question is, if anybody has solved this problem, or any suggestions on how to detect if I’m editing vs deleting?
The only useful way for Keyboard Maestro to differentiate it is if the window changes name to indicate which you are doing. Then you can make your macro group enabled only then the window name is such that you want delete to delete a message.
Alternatively, maybe you could have the Delete key execute a macro that runs a JavaScript that determines the state, but my guess is that that will be too slow to work well when you're editing and want to press the delete key multiple times in rapid succession.
This is a perennial question, and the answer is not satisfying at all...
macOS does not provide a nice neat API for utility apps to discover the edit state. Sometimes there are ways around this, but they tend to be slow, cumbersome, and not entirely reliable.
Your simplest solution here is to bind to Opt-Shift-Delete or some other easy to hit permutation.