Skip to content

Instantly share code, notes, and snippets.

@thattomperson
Created September 10, 2014 00:16
Show Gist options
  • Select an option

  • Save thattomperson/b5b8c4c7d545e94d080b to your computer and use it in GitHub Desktop.

Select an option

Save thattomperson/b5b8c4c7d545e94d080b to your computer and use it in GitHub Desktop.
(function (a, b) {
a.keydown(function (e) {
if( e.target.type !== 'text') {
switch (e.which) {
case 37: // left
Search.pagination.prev();
break;
case 39: // right
Search.pagination.next();
break;
}
}
});
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13];
var rotated = false;
function nextKey(e, i) {
if (konami[i] === 13) {
var deg = 180;
if (rotated) {
rotated = false;
deg = 0
} else {
rotated = true;
}
b.css({
transform: 'rotateY(' + deg + 'deg)',
transition: 'transform 2s'
});
} else {
if (e.which === konami[i]) {
a.one('keydown', function (e) {
nextKey(e, i + 1);
});
}
}
}
$(document).keydown(function (e) {
nextKey(e, 0);
});
}($(document), $(document.body)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment