If it’s a default behavior that ESC closes a modal, you should not change this default behavior. The user expects that ESC can be used to close.
You can you explain what you want to achieve? Maybe it’s better to use a normal page instead of a modal.
Seeing your comment at Henri, the solution is very simply.
Add a button on the page with action ‘Do nothing’ and add the CSS styling ‘display: none’. Then change the page properties (where you can change the page title) and at the bottom you can select which action you want to connect to the close button (that is also triggered by ESC key).
This way, if you press Esc, thus clicking on the X close button, you trigger the activity ‘Do nothing’.