Client Escape Keystroke Script does not fire when button has focus

I've set up a client keystroke script bound to the escape key when it is pressed. It determines which windows are pop ups (implicitly by checking maximizable/isMaximized props) and closes the first one in the list. Seems to work fine. However, when a button has been pressed that can take focus (aka be 'tabbed' to), the script no longer fires. I think this is a problem specifically with using the escape key as I've tried it with other keys and it seems to work regardless of if a button has focus or not. Can anybody shed some light on if this is the expected behaviour (possibly because the escape key has special purpose in the whole button tabbing/focussing behaviour?) Or if this is a bug?

Pretty sure this is java Swing behavior tied to "Cancel" default actions. You should use a different key.