If you have been annoyed like I did with Safari exiting full screen when you press escape key to cancel some dialog, there is easy solution to your problems.

Download karabiner-elements and install it. Karabiner Elements allow you to do simple and complex key modifications per key or per external keyboard or by any other criteria you might have.

After you install it, run it and to got Complex modifications tab. In the lower left corner press on Add rule button and then on Import more rules from the Internet button. You will be guided to the https://ke-complex-modifications.pqrs.org page where you can find all different kind of complex modifications you might think of. The one that you are interested at the moment is Application specific which there are 47 at the moment.

Application specific complex modifications

Expand this section and find following modification:

Don’t exit fullscreen when pressin ESC in Safari

Press import button and Safari will download it and automatically import it to Karabiner Elements.

Press Import button to install modification and you are done. Now we need to enable modification as well. On next screen you will have list of complex modifications and newly imported one should be there. To enable it, just press Enable button and that’s it!

Now list should look like this. Modification is imported and enabled and you can test it now in Safari. When you press Escape nothing should happen.

Karabiner Elements with modification installed.

Now you can close Karabiner Elements (it will continue running in background) and enjoy your full-screen Safari.