Commit cfa2c542 authored by Vadim Makeev's avatar Vadim Makeev

better Enter key handling

parent df0c517b
......@@ -53,9 +53,6 @@
case 32 : // Space
current += e.shiftKey ? -1 : 1;
break;
case 13 : // Enter
if(!current+1) enterFull();
break;
default:
prevent = false;
}
......@@ -79,7 +76,13 @@
updateProgress();
if(!isFull()) history.pushState(null, null, url.pathname + '?full' + url.hash);
window.addEventListener('resize', resizeFull, false);
document.addEventListener('keydown', exitFullEsc, false);
document.addEventListener('keyup', exitFullKey, false);
document.removeEventListener('keydown', enterFullKey, false);
}
function enterFullKey(e) {
if(e.which != 13) return;
enterFull();
}
function exitFull() {
......@@ -89,10 +92,11 @@
history.pushState(null, null, url.pathname.replace('?full', ''));
url.hash = hash;
window.removeEventListener('resize', resizeFull, false);
document.removeEventListener('keydown', exitFullEsc, false);
document.removeEventListener('keyup', exitFullKey, false);
document.addEventListener('keydown', enterFullKey, false);
}
function exitFullEsc(e) {
function exitFullKey(e) {
if(e.which != 27) return;
exitFull();
}
......@@ -110,5 +114,6 @@
if(isFull()) enterFull();
}, false);
document.addEventListener('keydown', turnSlide, false);
document.addEventListener('keydown', enterFullKey, false);
})();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment