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