Skip to content

Commit 6733f47

Browse files
committed
Pressing enter loads next page
When you press enter you will be redirected to the next step in the tutorial. See #20
1 parent a5d9534 commit 6733f47

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

js/playfield.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ window.addEventListener("load", function(){
167167
playfieldsLoaded = true;
168168
});
169169

170-
window.addEventListener("keypress", function(){
171-
var next = document.getElementsByClassName("next-page")[0].href;
172-
if (!(undefined === next | !next | next.length === 0)) {
173-
window.location.href = next;
170+
window.addEventListener("keypress", function(event){
171+
if (event.which === 13 || event.keyCode === 13) {
172+
var next = document.getElementsByClassName("next-page")[0].href;
173+
if (!(undefined === next || !next || next.length === 0)) {
174+
window.location.href = next;
175+
}
176+
return false;
174177
}
178+
return true;
175179
});

0 commit comments

Comments
 (0)