Сочетания клавиш по умолчанию почти неизвестны моей аудитории. Поэтому я не чувствую, что вина изменяет действия клавиатуры. < /P>
Q1. Я хотел бы повторно задать ключи со стрелками вверх и вниз, чтобы перейти к следующей/предыдущей радио -группе соответственно - с фокусом (вкладка Mimic и вкладка Shift+)
Q2. Я также хотел бы повторно задать клавишу Enter, чтобы выбрать текущую радиопроизводство и двигаться дальше - с фокусом (Mimic Space). Я не отправляю форму, поэтому у меня нет другого использования для клавиши Enter. < /P>
Мой неполный обработчик клавиатуры ниже. < /P>
Код: Выделить всё
window.addEventListener('keydown', function (e) {
// Process e object
var key = e.which
if (e.ctrlKey) { key = "ctrl"+key; }
if (e.altKey) { key = "alt"+key; }
if (e.shiftKey) { key = "shift"+key; }
// Ctrl+C
if (key == "ctrl67") {
// Preserve default
return;
}
// Ctrl+F
if (key == "ctrl70") {
// Preserve default
return;
}
// Radio Button Shortcuts
// Space
if (key == "32") {
// Preserve default
return;
}
// TAB
if (key == "9") {
// Preserve default
return;
}
// Shift+TAB
if (key == "shift9") {
// Preserve default
return;
}
// LeftArrow
if (key == "37") {
// Preserve default
return;
}
// RightArrow
if (key == "39") {
// Preserve default
return;
}
// Enter - if radio button send space
if (key == "13") {
if($("input[type=radio]").is(':focus')){
// Dissable default
e.preventDefault();
// Simulate Space
// TODO:
} else {
// Preserve default
return;
}
}
// DownArrow - if radio button send TAB
if (key == "40") {
if($("input[type=radio]").is(':focus')){
// Dissable default
e.preventDefault();
// Simulate TAB to move to next radio group
// TODO:
} else {
// Preserve default
return;
}
}
// UpArrow - if radio button send Shift+TAB
if (key == "38") {
if($("input[type=radio]").is(':focus')){
// Dissable default
e.preventDefault();
// Simulate Shift+TAB to move to prev radio group
// TODO:
} else {
// Preserve default
return;
}
}
// Dissable fall-through and all remaining keyboard shortcuts
e.preventDefault();
});
Подробнее здесь: https://stackoverflow.com/questions/794 ... dio-groups
Мобильная версия