|
1166 | 1166 | */ |
1167 | 1167 | function fadeOut( event ) { |
1168 | 1168 | var isMac, |
1169 | | - key = event && event.keyCode; |
| 1169 | + key = event && event.key; |
1170 | 1170 |
|
1171 | 1171 | if ( window.navigator.platform ) { |
1172 | 1172 | isMac = ( window.navigator.platform.indexOf( 'Mac' ) > -1 ); |
1173 | 1173 | } |
1174 | 1174 |
|
1175 | 1175 | // Fade in and returns on Escape and keyboard shortcut Alt+Shift+W and Ctrl+Opt+W. |
1176 | | - if ( key === 27 || ( key === 87 && event.altKey && ( ( ! isMac && event.shiftKey ) || ( isMac && event.ctrlKey ) ) ) ) { |
| 1176 | + if ( key === 'Escape' || ( key === 'w' && event.altKey && ( ( ! isMac && event.shiftKey ) || ( isMac && event.ctrlKey ) ) ) ) { |
1177 | 1177 | fadeIn( event ); |
1178 | 1178 | return; |
1179 | 1179 | } |
1180 | 1180 |
|
1181 | 1181 | // Return if any of the following keys or combinations of keys is pressed. |
1182 | 1182 | if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && ( |
1183 | 1183 | // Special keys ( tab, ctrl, alt, esc, arrow keys... ). |
1184 | | - ( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) || |
| 1184 | + ( ['Tab', 'Control', 'Alt', 'Shift', 'Escape', 'CapsLock', 'NumLock', 'ScrollLock', 'Pause', 'Insert', 'Home', 'End', 'PageUp', 'PageDown', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PrintScreen'].includes(key) ) || |
1185 | 1185 | // Windows keys. |
1186 | | - ( key >= 91 && key <= 93 ) || |
| 1186 | + ( ['Meta', 'OS', 'ContextMenu'].includes(key) ) || |
1187 | 1187 | // F keys. |
1188 | | - ( key >= 112 && key <= 135 ) || |
1189 | | - // Num Lock, Scroll Lock, OEM. |
1190 | | - ( key >= 144 && key <= 150 ) || |
| 1188 | + ( /^F([1-9]|1[0-9]|2[0-4])$/.test(key) ) || |
1191 | 1189 | // OEM or non-printable. |
1192 | | - key >= 224 |
| 1190 | + key.startsWith('Dead') || |
| 1191 | + key === 'Unidentified' || |
| 1192 | + key.length > 1 && !['Enter', 'Backspace', 'Delete', ' '].includes(key) |
1193 | 1193 | ) ) ) ) { |
1194 | 1194 | return; |
1195 | 1195 | } |
|
1446 | 1446 | * @return {void} |
1447 | 1447 | */ |
1448 | 1448 | function toggleViaKeyboard( event ) { |
1449 | | - if ( event.altKey && event.shiftKey && 87 === event.keyCode ) { |
| 1449 | + if ( event.altKey && event.shiftKey && 'w' === event.key ) { |
1450 | 1450 | toggle(); |
1451 | 1451 | } |
1452 | 1452 | } |
|
0 commit comments