2016-11-17 05:55:05 +00:00
|
|
|
function arrowKeys(e) {
|
2017-05-08 02:58:29 +00:00
|
|
|
switch(e.keyCode) {
|
|
|
|
case 39:
|
|
|
|
var prev = document.getElementById('prev');
|
|
|
|
if(prev) prev.click();
|
|
|
|
break;
|
|
|
|
case 37:
|
|
|
|
var next = document.getElementById('next');
|
|
|
|
if(next) next.click();
|
|
|
|
break;
|
|
|
|
case 82:
|
|
|
|
var random = document.getElementById('random');
|
|
|
|
if(random) random.click();
|
|
|
|
}
|
2016-11-17 05:55:05 +00:00
|
|
|
}
|
|
|
|
if(document.readyState == 'complete' || document.readyState == 'loaded')
|
2017-05-08 02:58:29 +00:00
|
|
|
document.addEventListener('keydown', arrowKeys);
|
2016-11-17 05:55:05 +00:00
|
|
|
else {
|
2017-05-08 02:58:29 +00:00
|
|
|
if(/Chrome/i.test(navigator.userAgent))
|
|
|
|
window.addEventListener('load', function () {
|
|
|
|
document.addEventListener('keydown', arrowKeys);
|
|
|
|
});
|
|
|
|
else
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
document.addEventListener('keydown', arrowKeys);
|
|
|
|
});
|
2016-11-17 05:55:05 +00:00
|
|
|
}
|