Motivation:
ESC worked only on first open because the listener was registered inside the first-time DOM creation block. On close(), it was detached. On subsequent show() calls, the modal DOM already existed so the function returned early — the listener was NEVER re-attached.
Implementation:
Extracted listener management into two symmetric private methods: _attachEscListener() and _detachEscListener(). show() now calls _attachEscListener on EVERY open (both first-time and subsequent). _closeModal is stored as an instance method so it can be referenced on re-opens. closeModal() calls _detachEscListener() symmetrically. This pattern is leak-proof and correctly re-attaches on every modal activation.