Commit cfa2c542 authored by Vadim Makeev's avatar Vadim Makeev

better Enter key handling

parent df0c517b
...@@ -53,9 +53,6 @@ ...@@ -53,9 +53,6 @@
case 32 : // Space case 32 : // Space
current += e.shiftKey ? -1 : 1; current += e.shiftKey ? -1 : 1;
break; break;
case 13 : // Enter
if(!current+1) enterFull();
break;
default: default:
prevent = false; prevent = false;
} }
...@@ -79,7 +76,13 @@ ...@@ -79,7 +76,13 @@
updateProgress(); updateProgress();
if(!isFull()) history.pushState(null, null, url.pathname + '?full' + url.hash); if(!isFull()) history.pushState(null, null, url.pathname + '?full' + url.hash);
window.addEventListener('resize', resizeFull, false); 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() { function exitFull() {
...@@ -89,10 +92,11 @@ ...@@ -89,10 +92,11 @@
history.pushState(null, null, url.pathname.replace('?full', '')); history.pushState(null, null, url.pathname.replace('?full', ''));
url.hash = hash; url.hash = hash;
window.removeEventListener('resize', resizeFull, false); 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; if(e.which != 27) return;
exitFull(); exitFull();
} }
...@@ -110,5 +114,6 @@ ...@@ -110,5 +114,6 @@
if(isFull()) enterFull(); if(isFull()) enterFull();
}, false); }, false);
document.addEventListener('keydown', turnSlide, 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