fix keybindings

This commit is contained in:
jkhsjdhjs 2017-12-03 00:06:30 +01:00
parent c75ed00bcc
commit f73b67d74f

View File

@ -1,10 +1,4 @@
const keybindings = { const clickOnElementBinding = selector => {
"ArrowLeft": clickOnElementBinding("#next"),
"ArrowRight": clickOnElementBinding("#prev"),
"r": clickOnElementBinding("#random")
};
const clickOnElementBinding(selector) = () => {
return () => { return () => {
const elem = document.querySelector(selector); const elem = document.querySelector(selector);
if(elem) if(elem)
@ -12,6 +6,12 @@ const clickOnElementBinding(selector) = () => {
}; };
}; };
const keybindings = {
"ArrowLeft": clickOnElementBinding("#next"),
"ArrowRight": clickOnElementBinding("#prev"),
"r": clickOnElementBinding("#random")
};
(() => { (() => {
document.addEventListener("keydown", e => { document.addEventListener("keydown", e => {
if(e.key in keybindings) { if(e.key in keybindings) {