mirror of
https://github.com/pldubouilh/gossa
synced 2025-12-06 08:22:32 +01:00
Work around Firefox's transient activation requirement for opening the file picker (allow using shift as modifier)
This commit is contained in:
parent
31c8ee518a
commit
3ebceb5e76
1 changed files with 36 additions and 24 deletions
60
ui/script.js
vendored
60
ui/script.js
vendored
|
|
@ -749,40 +749,52 @@ document.body.addEventListener('keydown', e => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ctrl keys
|
// Modifier keys
|
||||||
if ((e.ctrlKey || e.metaKey) && !e.shiftKey) {
|
if (!e.shiftKey) {
|
||||||
switch (e.code) {
|
if (e.ctrlKey || e.metaKey) {
|
||||||
case 'KeyC':
|
switch (e.code) {
|
||||||
return prevent(e) || isRo() || cpPath()
|
case 'KeyC':
|
||||||
|
return prevent(e) || isRo() || cpPath()
|
||||||
|
|
||||||
case 'KeyH':
|
case 'KeyH':
|
||||||
return prevent(e) || isRo() || helpToggle()
|
return prevent(e) || isRo() || helpToggle()
|
||||||
|
|
||||||
case 'KeyX':
|
case 'KeyX':
|
||||||
return prevent(e) || isRo() || onCut()
|
return prevent(e) || isRo() || onCut()
|
||||||
|
|
||||||
case 'KeyR':
|
case 'KeyR':
|
||||||
return prevent(e) || refresh()
|
return prevent(e) || refresh()
|
||||||
|
|
||||||
case 'KeyV':
|
case 'KeyV':
|
||||||
return prevent(e) || isRo() || ensureMove() || onPaste()
|
return prevent(e) || isRo() || ensureMove() || onPaste()
|
||||||
|
|
||||||
case 'Backspace':
|
case 'Backspace':
|
||||||
return prevent(e) || isRo() || window.rm(e)
|
return prevent(e) || isRo() || window.rm(e)
|
||||||
|
|
||||||
case 'KeyE':
|
case 'KeyE':
|
||||||
return prevent(e) || isRo() || window.rename(e)
|
return prevent(e) || isRo() || window.rename(e)
|
||||||
|
|
||||||
case 'KeyM':
|
case 'KeyM':
|
||||||
return prevent(e) || isRo() || window.mkdirBtn()
|
return prevent(e) || isRo() || window.mkdirBtn()
|
||||||
|
|
||||||
case 'KeyU':
|
case 'KeyU':
|
||||||
return prevent(e) || isRo() || manualUpload.click()
|
return prevent(e) || isRo() || manualUpload.click()
|
||||||
|
|
||||||
case 'Enter':
|
case 'Enter':
|
||||||
case 'ArrowRight':
|
case 'ArrowRight':
|
||||||
return prevent(e) || dl(getASelected())
|
return prevent(e) || dl(getASelected())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Workaround Firefox requirement for transient activation
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Security/User_activation
|
||||||
|
// Firefox requires user interaction (that is not reserved by the user agent)
|
||||||
|
// before a file picker can be displayed. This means that ctrl/meta are not
|
||||||
|
// usable as modifiers until the user clicks the page or presses another
|
||||||
|
// non-modifier key. To work around this, the shift key can be used, instead.
|
||||||
|
if (e.code == 'KeyU') {
|
||||||
|
return prevent(e) || isRo() || manualUpload.click()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (e.code) {
|
switch (e.code) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue