Run the attached app to reproduce the issue. It has three buttons and a TextField.
Press ESC when focus is not on the TextField. "Cancel button action invoked" is printed in output window.
Press Enter when focus in in the TextField. "Default button action invoked" is printed in output window.
Remove buttons from the screen using "remove buttons" button.
Repeat steps above. The actions are still invoked. It must not happen.
Press ESC when focus is not on the TextField. "Cancel button action invoked" is printed in output window.
Press Enter when focus in in the TextField. "Default button action invoked" is printed in output window.
Remove buttons from the screen using "remove buttons" button.
Repeat steps above. The actions are still invoked. It must not happen.