This commit is contained in:
Utopiah
2026-08-05 18:53:08 +02:00
parent 86f0c98ed0
commit 9eea6586e8
+8 -1
View File
@@ -21,6 +21,7 @@ function onError(error) {
let key, modifiers = []
let seq = ''
let richSeq = ''
document.addEventListener("keydown", function(event) {
if (event.key.length === 1 || event.key === event.code) {
@@ -29,9 +30,13 @@ document.addEventListener("keydown", function(event) {
if (key == 'Escape') {
seq = ''
modifiers = []
richSeq = ''
return
}
if ( event.key.length === 1) seq += key // does not take modifiers into account per key, e.g. IoT works but not ^i^o^t
if ( event.key.length === 1) {
seq += key // does not take modifiers into account per key, e.g. IoT works but not ^i^o^t
richSeq += modifiers.join('') + key
}
} else {
// 'Alt', 'Control', 'Shift'
modifiers.push( event.key )
@@ -66,6 +71,7 @@ document.addEventListener("keyup", function(event) {
// could then grow userActions by the user themselves, save in localStorage, etc without having to rebuild extension
// note that i is different from I (which is here captured as I + Shift)
let userActions = [
// consider richSeq instead
{ seq: 'gtm', action: 'window.open("https://twitter-archive.benetou.fr/")'},
{ seq: 'gg', action: 'window.scrollTo(0, 0)'},
{ key: 'G', mods: ['Shift'], action: 'window.scrollTo(0, document.body.scrollHeight)'},
@@ -74,6 +80,7 @@ let userActions = [
{ key: 'r', action: 'window.location.reload()'},
{ key: 'x', action: 'autoscroll()'},
{ key: 'b', action: 'history.back()'},
{ key: 'B', mods: ['Shift'], action: 'blocked = !blocked'}, // can not be unblocked, need to refresh the page
{ key: 'a', action: 'addWiki()'},
{ key: 'n', action: 'firstTab()'},
{ key: 'P', mods: ['Shift'], action: 'window.open("https://account.proton.me/")'},