Key board escape button functionality to close the pop up

Hi Friends

Can anyone help me with my requirement. I want to close the message box or pop up generated by pressing the escape button on the key board. Is there any specific code for it or any function. Please help me on this requirement. I have attached an image for reference. I want to close these box on escape button.

Thanks

Huh. Not sure. But the space bar should work.

Works for me using system.gui.messageBox() on v7.8.4