mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
nav: fix key navigation when pressing wrong modifiers #379
This commit is contained in:
parent
0c39b33f5b
commit
7b0b56dee4
1 changed files with 14 additions and 12 deletions
|
@ -348,12 +348,14 @@ function initArrowNav(){
|
||||||
|
|
||||||
// keyboard navigation
|
// keyboard navigation
|
||||||
jQuery(document).keydown(function(e) {
|
jQuery(document).keydown(function(e) {
|
||||||
if(e.which == '37') {
|
if(!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey){
|
||||||
jQuery('a.nav-prev').click();
|
if(e.which == '37') {
|
||||||
}
|
jQuery('a.nav-prev').click();
|
||||||
if(e.which == '39') {
|
}
|
||||||
jQuery('a.nav-next').click();
|
if(e.which == '39') {
|
||||||
}
|
jQuery('a.nav-next').click();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// avoid keyboard navigation for input fields
|
// avoid keyboard navigation for input fields
|
||||||
|
@ -475,25 +477,25 @@ function tocEscapeHandler( event ){
|
||||||
}
|
}
|
||||||
|
|
||||||
function sidebarShortcutHandler( event ){
|
function sidebarShortcutHandler( event ){
|
||||||
if( event.altKey && event.ctrlKey && event.which == 78 /* n */ ){
|
if( !event.shiftKey && event.altKey && event.ctrlKey && !event.metaKey && event.which == 78 /* n */ ){
|
||||||
showNav();
|
showNav();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tocShortcutHandler( event ){
|
function tocShortcutHandler( event ){
|
||||||
if( event.altKey && event.ctrlKey && event.which == 84 /* t */ ){
|
if( !event.shiftKey && event.altKey && event.ctrlKey && !event.metaKey && event.which == 84 /* t */ ){
|
||||||
showToc();
|
showToc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editShortcutHandler( event ){
|
function editShortcutHandler( event ){
|
||||||
if( event.altKey && event.ctrlKey && event.which == 87 /* w */ ){
|
if( !event.shiftKey && event.altKey && event.ctrlKey && !event.metaKey && event.which == 87 /* w */ ){
|
||||||
showEdit();
|
showEdit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printShortcutHandler( event ){
|
function printShortcutHandler( event ){
|
||||||
if( event.altKey && event.ctrlKey && event.which == 80 /* p */ ){
|
if( !event.shiftKey && event.altKey && event.ctrlKey && !event.metaKey && event.which == 80 /* p */ ){
|
||||||
showPrint();
|
showPrint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,8 +563,8 @@ function initToc(){
|
||||||
document.addEventListener( 'keydown', tocShortcutHandler );
|
document.addEventListener( 'keydown', tocShortcutHandler );
|
||||||
// avoid keyboard navigation for input fields
|
// avoid keyboard navigation for input fields
|
||||||
jQuery(formelements).keydown(function (e) {
|
jQuery(formelements).keydown(function (e) {
|
||||||
if( e.altKey && event.ctrlKey ){
|
if( !e.shiftKey && e.altKey && e.ctrlKey && !e.metaKey){
|
||||||
if( e.which == 77 /* m */ || e.which == 84 /* t */ || e.which == 69 /* e */ || e.which == 80 /* p */ ){
|
if( e.which == 78 /* n */ || e.which == 84 /* t */ || e.which == 87 /* w */ || e.which == 80 /* p */ ){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue