Skip to content
Snippets Groups Projects
Commit 0276880f authored by Loc Nguyen's avatar Loc Nguyen
Browse files

replace deprecated keyCode for key

parent 98a3ae92
No related branches found
No related tags found
2 merge requests!478Automated merge from preview to main,!460fix accessability issues
// keyboard navigation // keyboard navigation
// allow to expand navigation items with nested items by specified keys // allow to expand navigation items with nested items by
let nav_links = document.querySelectorAll('.md-nav__link'); let nav_links = document.querySelectorAll('.md-nav__link');
Array.from(nav_links).forEach(label => { Array.from(nav_links).forEach(label => {
label.addEventListener('keydown', e => { label.addEventListener('keydown', e => {
// 13 === Enter if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowLeft'|| e.key === 'ArrowRight') {
// 32 === Spacebar
// 37 === ArrowLeft
// 39 === ArrowRight
if (e.keyCode === 13 || e.keyCode === 32 || e.keyCode ===37 || e.keyCode === 39) {
e.preventDefault(); e.preventDefault();
label.click(); label.click();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment