@@ -46,10 +46,10 @@ const A11y = {
4646 $el . attr ( 'aria-disabled' , false ) ;
4747 return $el ;
4848 } ,
49- onEnterKey ( e ) {
49+ onEnterOrSpaceKey ( e ) {
50+ if ( e . keyCode !== 13 && e . keyCode !== 32 ) return ;
5051 const swiper = this ;
5152 const params = swiper . params . a11y ;
52- if ( e . keyCode !== 13 ) return ;
5353 const $targetEl = $ ( e . target ) ;
5454 if ( swiper . navigation && swiper . navigation . $nextEl && $targetEl . is ( swiper . navigation . $nextEl ) ) {
5555 if ( ! ( swiper . isEnd && ! swiper . params . loop ) ) {
@@ -184,7 +184,7 @@ const A11y = {
184184 swiper . a11y . makeElFocusable ( $nextEl ) ;
185185 if ( $nextEl [ 0 ] . tagName !== 'BUTTON' ) {
186186 swiper . a11y . addElRole ( $nextEl , 'button' ) ;
187- $nextEl . on ( 'keydown' , swiper . a11y . onEnterKey ) ;
187+ $nextEl . on ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
188188 }
189189 swiper . a11y . addElLabel ( $nextEl , params . nextSlideMessage ) ;
190190 swiper . a11y . addElControls ( $nextEl , wrapperId ) ;
@@ -193,7 +193,7 @@ const A11y = {
193193 swiper . a11y . makeElFocusable ( $prevEl ) ;
194194 if ( $prevEl [ 0 ] . tagName !== 'BUTTON' ) {
195195 swiper . a11y . addElRole ( $prevEl , 'button' ) ;
196- $prevEl . on ( 'keydown' , swiper . a11y . onEnterKey ) ;
196+ $prevEl . on ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
197197 }
198198 swiper . a11y . addElLabel ( $prevEl , params . prevSlideMessage ) ;
199199 swiper . a11y . addElControls ( $prevEl , wrapperId ) ;
@@ -209,7 +209,7 @@ const A11y = {
209209 swiper . pagination . $el . on (
210210 'keydown' ,
211211 `.${ swiper . params . pagination . bulletClass . replace ( / / g, '.' ) } ` ,
212- swiper . a11y . onEnterKey ,
212+ swiper . a11y . onEnterOrSpaceKey ,
213213 ) ;
214214 }
215215 } ,
@@ -227,10 +227,10 @@ const A11y = {
227227 $prevEl = swiper . navigation . $prevEl ;
228228 }
229229 if ( $nextEl ) {
230- $nextEl . off ( 'keydown' , swiper . a11y . onEnterKey ) ;
230+ $nextEl . off ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
231231 }
232232 if ( $prevEl ) {
233- $prevEl . off ( 'keydown' , swiper . a11y . onEnterKey ) ;
233+ $prevEl . off ( 'keydown' , swiper . a11y . onEnterOrSpaceKey ) ;
234234 }
235235
236236 // Pagination
@@ -243,7 +243,7 @@ const A11y = {
243243 swiper . pagination . $el . off (
244244 'keydown' ,
245245 `.${ swiper . params . pagination . bulletClass . replace ( / / g, '.' ) } ` ,
246- swiper . a11y . onEnterKey ,
246+ swiper . a11y . onEnterOrSpaceKey ,
247247 ) ;
248248 }
249249 } ,
0 commit comments