File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,13 @@ export default {
91
91
if (this .closeOnBackdrop && e .target .id && e .target .id === this .id ) {
92
92
this .hide ();
93
93
}
94
+ },
95
+ pressedButton (e ) {
96
+ // support for esc key press
97
+ const key = e .which || e .keyCode ;
98
+ if (key === 27 ) { // 27 is esc
99
+ this .hide ();
100
+ }
94
101
}
95
102
},
96
103
created () {
@@ -99,16 +106,11 @@ export default {
99
106
hub .$on (' hide::modal' , id => id === this .id && this .hide ());
100
107
},
101
108
mounted () {
102
- // support for esc key press
103
- document .addEventListener (' keydown' , e => {
104
- const key = e .which || e .keyCode ;
105
- if (key === 27 ) { // 27 is esc
106
- this .hide ();
107
- }
108
- });
109
+ document .addEventListener (' keydown' , this .pressedButton );
109
110
},
110
111
destroyed () {
111
112
clearTimeout (this ._modalAnimation );
113
+ document .removeEventListener (' keydown' , this .pressedButton );
112
114
}
113
115
};
114
116
You can’t perform that action at this time.
0 commit comments