@@ -46,10 +46,10 @@ const A11y = {
46
46
$el . attr ( 'aria-disabled' , false ) ;
47
47
return $el ;
48
48
} ,
49
- onEnterKey ( e ) {
49
+ onEnterOrSpaceKey ( e ) {
50
+ if ( e . keyCode !== 13 && e . keyCode !== 32 ) return ;
50
51
const swiper = this ;
51
52
const params = swiper . params . a11y ;
52
- if ( e . keyCode !== 13 ) return ;
53
53
const $targetEl = $ ( e . target ) ;
54
54
if ( swiper . navigation && swiper . navigation . $nextEl && $targetEl . is ( swiper . navigation . $nextEl ) ) {
55
55
if ( ! ( swiper . isEnd && ! swiper . params . loop ) ) {
@@ -184,7 +184,7 @@ const A11y = {
184
184
swiper . a11y . makeElFocusable ( $nextEl ) ;
185
185
if ( $nextEl [ 0 ] . tagName !== 'BUTTON' ) {
186
186
swiper . a11y . addElRole ( $nextEl , 'button' ) ;
187
- $nextEl . on ( 'keydown' , swiper . a11y . onEnterKey ) ;
187
+ $nextEl . on ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
188
188
}
189
189
swiper . a11y . addElLabel ( $nextEl , params . nextSlideMessage ) ;
190
190
swiper . a11y . addElControls ( $nextEl , wrapperId ) ;
@@ -193,7 +193,7 @@ const A11y = {
193
193
swiper . a11y . makeElFocusable ( $prevEl ) ;
194
194
if ( $prevEl [ 0 ] . tagName !== 'BUTTON' ) {
195
195
swiper . a11y . addElRole ( $prevEl , 'button' ) ;
196
- $prevEl . on ( 'keydown' , swiper . a11y . onEnterKey ) ;
196
+ $prevEl . on ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
197
197
}
198
198
swiper . a11y . addElLabel ( $prevEl , params . prevSlideMessage ) ;
199
199
swiper . a11y . addElControls ( $prevEl , wrapperId ) ;
@@ -209,7 +209,7 @@ const A11y = {
209
209
swiper . pagination . $el . on (
210
210
'keydown' ,
211
211
`.${ swiper . params . pagination . bulletClass . replace ( / / g, '.' ) } ` ,
212
- swiper . a11y . onEnterKey ,
212
+ swiper . a11y . onEnterOrSpaceKey ,
213
213
) ;
214
214
}
215
215
} ,
@@ -227,10 +227,10 @@ const A11y = {
227
227
$prevEl = swiper . navigation . $prevEl ;
228
228
}
229
229
if ( $nextEl ) {
230
- $nextEl . off ( 'keydown' , swiper . a11y . onEnterKey ) ;
230
+ $nextEl . off ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
231
231
}
232
232
if ( $prevEl ) {
233
- $prevEl . off ( 'keydown' , swiper . a11y . onEnterKey ) ;
233
+ $prevEl . off ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
234
234
}
235
235
236
236
// Pagination
@@ -243,7 +243,7 @@ const A11y = {
243
243
swiper . pagination . $el . off (
244
244
'keydown' ,
245
245
`.${ swiper . params . pagination . bulletClass . replace ( / / g, '.' ) } ` ,
246
- swiper . a11y . onEnterKey ,
246
+ swiper . a11y . onEnterOrSpaceKey ,
247
247
) ;
248
248
}
249
249
} ,
0 commit comments