update keybindings

This commit is contained in:
jkhsjdhjs 2017-12-02 23:44:21 +01:00
parent c572b84026
commit c75ed00bcc

View File

@ -1,19 +1,19 @@
const keybindings = {
'ArrowLeft': clickOnElementBinding('#next'),
'ArrowRight': clickOnElementBinding('#prev'),
'r': clickOnElementBinding('#random')
"ArrowLeft": clickOnElementBinding("#next"),
"ArrowRight": clickOnElementBinding("#prev"),
"r": clickOnElementBinding("#random")
};
function clickOnElementBinding(selector) {
const clickOnElementBinding(selector) = () => {
return () => {
let elem = document.querySelector(selector);
const elem = document.querySelector(selector);
if(elem)
elem.click();
};
}
};
(function() {
document.addEventListener('keydown', e => {
(() => {
document.addEventListener("keydown", e => {
if(e.key in keybindings) {
e.preventDefault();
keybindings[e.key]();