File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ function PhpbbWebpush() {
3333 /** @type {HTMLElement } Unsubscribe button */
3434 let unsubscribeButton ;
3535
36+ /** @type {function } Escape key handler for popup */
37+ let popupEscapeHandler ;
38+
3639 /**
3740 * Init function for phpBB Web Push
3841 * @type {array } options
@@ -185,6 +188,15 @@ function PhpbbWebpush() {
185188 promptDenied . set ( ) ;
186189 }
187190 } ) ;
191+
192+ popupEscapeHandler = ( event ) => {
193+ if ( event . key === 'Escape' ) {
194+ hidePopup ( popup ) ;
195+ promptDenied . set ( ) ;
196+ }
197+ } ;
198+
199+ document . addEventListener ( 'keydown' , popupEscapeHandler ) ;
188200 }
189201 }
190202
@@ -196,6 +208,8 @@ function PhpbbWebpush() {
196208 if ( popup ) {
197209 popup . style . display = 'none' ;
198210 }
211+ document . removeEventListener ( 'keydown' , popupEscapeHandler ) ;
212+ popupEscapeHandler = null ;
199213 }
200214
201215 /**
You can’t perform that action at this time.
0 commit comments