update keybindings
This commit is contained in:
parent
c572b84026
commit
c75ed00bcc
16
s/shit.js
16
s/shit.js
|
@ -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]();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user