File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
1818 super . connectedCallback ( ) ;
1919 window . addEventListener ( 'click' , this . _handleOutsideInteraction ) ;
2020 window . addEventListener ( 'focusin' , this . _handleOutsideInteraction ) ;
21+ window . addEventListener ( 'keydown' , this . _handleKeyDown ) ;
2122 }
2223
2324 public disconnectedCallback ( ) : void {
2425 window . removeEventListener ( 'click' , this . _handleOutsideInteraction ) ;
2526 window . removeEventListener ( 'focusin' , this . _handleOutsideInteraction ) ;
27+ window . removeEventListener ( 'keydown' , this . _handleKeyDown ) ;
2628 super . disconnectedCallback ( ) ;
2729 }
2830
@@ -125,6 +127,14 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
125127 }
126128 } ;
127129
130+ protected _handleKeyDown = ( ev : KeyboardEvent ) : void => {
131+ if ( ev . key === 'Escape' ) {
132+ this . _dismiss ( ) ;
133+ ev . stopPropagation ( ) ;
134+ ev . preventDefault ( ) ;
135+ }
136+ } ;
137+
128138 static get styles ( ) : CSSResultGroup {
129139 return unsafeCSS ( overlayMessageStyle ) ;
130140 }
You can’t perform that action at this time.
0 commit comments