@@ -909,7 +909,7 @@ themes.view.Preview = themes.view.Details.extend({
909909 'click .devices button' : 'previewDevice' ,
910910 'click .previous-theme' : 'previousTheme' ,
911911 'click .next-theme' : 'nextTheme' ,
912- 'keyup ' : 'keyEvent' ,
912+ 'keydown ' : 'keyEvent' ,
913913 'click .theme-install' : 'installTheme'
914914 } ,
915915
@@ -1012,18 +1012,20 @@ themes.view.Preview = themes.view.Details.extend({
10121012 this . close ( ) ;
10131013 }
10141014
1015- // Return if Ctrl + Shift or Shift key pressed
1016- if ( event . shiftKey || ( event . ctrlKey && event . shiftKey ) ) {
1015+ // Arrow key navigation requires Alt key to avoid interfering with screen reader navigation.
1016+ if ( ! event . altKey || event . repeat ) {
10171017 return ;
10181018 }
10191019
10201020 // The right arrow key, next theme.
10211021 if ( event . keyCode === 39 ) {
1022- _ . once ( this . nextTheme ( ) ) ;
1022+ event . preventDefault ( ) ;
1023+ this . nextTheme ( ) ;
10231024 }
10241025
10251026 // The left arrow key, previous theme.
10261027 if ( event . keyCode === 37 ) {
1028+ event . preventDefault ( ) ;
10271029 this . previousTheme ( ) ;
10281030 }
10291031 } ,
@@ -1111,7 +1113,7 @@ themes.view.Themes = wp.Backbone.View.extend({
11111113 } ) ;
11121114
11131115 // Bind keyboard events.
1114- $ ( 'body' ) . on ( 'keyup ' , function ( event ) {
1116+ $ ( 'body' ) . on ( 'keydown.wp-themes ' , function ( event ) {
11151117 if ( ! self . overlay ) {
11161118 return ;
11171119 }
@@ -1121,25 +1123,27 @@ themes.view.Themes = wp.Backbone.View.extend({
11211123 return ;
11221124 }
11231125
1124- // Return if Ctrl + Shift or Shift key pressed
1125- if ( event . shiftKey || ( event . ctrlKey && event . shiftKey ) ) {
1126+ // Pressing the escape key fires a theme:collapse event.
1127+ if ( event . keyCode === 27 ) {
1128+ self . overlay . collapse ( event ) ;
1129+ }
1130+
1131+ // Arrow key navigation requires Alt key to avoid interfering with screen reader navigation.
1132+ if ( ! event . altKey || event . repeat ) {
11261133 return ;
11271134 }
11281135
1129- // Pressing the right arrow key fires a theme:next event.
1136+ // Pressing Alt + right arrow key fires a theme:next event.
11301137 if ( event . keyCode === 39 ) {
1138+ event . preventDefault ( ) ;
11311139 self . overlay . nextTheme ( ) ;
11321140 }
11331141
1134- // Pressing the left arrow key fires a theme:previous event.
1142+ // Pressing Alt + left arrow key fires a theme:previous event.
11351143 if ( event . keyCode === 37 ) {
1144+ event . preventDefault ( ) ;
11361145 self . overlay . previousTheme ( ) ;
11371146 }
1138-
1139- // Pressing the escape key fires a theme:collapse event.
1140- if ( event . keyCode === 27 ) {
1141- self . overlay . collapse ( event ) ;
1142- }
11431147 } ) ;
11441148 } ,
11451149
0 commit comments