mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Use key instead of code
This commit is contained in:
parent
28b1b34b00
commit
a1c09c6c53
1 changed files with 12 additions and 12 deletions
|
@ -44,19 +44,19 @@ function isOK(event: KeyboardEvent): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyCodes: ShortcutKeyMap = {
|
const keyCodes: ShortcutKeyMap = {
|
||||||
KeyJ() { click('.js-prev'); }, // J - go to previous image
|
'j'() { click('.js-prev'); }, // J - go to previous image
|
||||||
KeyI() { click('.js-up'); }, // I - go to index page
|
'i'() { click('.js-up'); }, // I - go to index page
|
||||||
KeyK() { click('.js-next'); }, // K - go to next image
|
'k'() { click('.js-next'); }, // K - go to next image
|
||||||
KeyR() { click('.js-rand'); }, // R - go to random image
|
'r'() { click('.js-rand'); }, // R - go to random image
|
||||||
KeyS() { click('.js-source-link'); }, // S - go to image source
|
's'() { click('.js-source-link'); }, // S - go to image source
|
||||||
KeyL() { click('.js-tag-sauce-toggle'); }, // L - edit tags
|
'l'() { click('.js-tag-sauce-toggle'); }, // L - edit tags
|
||||||
KeyO() { openFullView(); }, // O - open original
|
'o'() { openFullView(); }, // O - open original
|
||||||
KeyV() { openFullViewNewTab(); }, // V - open original in a new tab
|
'v'() { openFullViewNewTab(); }, // V - open original in a new tab
|
||||||
KeyF() { // F - favourite image
|
'f'() { // F - favourite image
|
||||||
click(getHover() ? `a.interaction--fave[data-image-id="${getHover()}"]`
|
click(getHover() ? `a.interaction--fave[data-image-id="${getHover()}"]`
|
||||||
: '.block__header a.interaction--fave');
|
: '.block__header a.interaction--fave');
|
||||||
},
|
},
|
||||||
KeyU() { // U - upvote image
|
'u'() { // U - upvote image
|
||||||
click(getHover() ? `a.interaction--upvote[data-image-id="${getHover()}"]`
|
click(getHover() ? `a.interaction--upvote[data-image-id="${getHover()}"]`
|
||||||
: '.block__header a.interaction--upvote');
|
: '.block__header a.interaction--upvote');
|
||||||
},
|
},
|
||||||
|
@ -64,8 +64,8 @@ const keyCodes: ShortcutKeyMap = {
|
||||||
|
|
||||||
export function listenForKeys() {
|
export function listenForKeys() {
|
||||||
document.addEventListener('keydown', (event: KeyboardEvent) => {
|
document.addEventListener('keydown', (event: KeyboardEvent) => {
|
||||||
if (isOK(event) && keyCodes[event.code]) {
|
if (isOK(event) && keyCodes[event.key]) {
|
||||||
keyCodes[event.code]();
|
keyCodes[event.key]();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue