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