Move Escape keyboard shortcut to shortcuts.js
This commit is contained in:
@@ -96,9 +96,6 @@ function init () {
|
||||
// ...same thing if you paste a torrent
|
||||
document.addEventListener('paste', onPaste)
|
||||
|
||||
// ...keyboard shortcuts
|
||||
document.addEventListener('keydown', onKeyDown)
|
||||
|
||||
// ...focus and blur. Needed to show correct dock icon text ("badge") in OSX
|
||||
window.addEventListener('focus', onFocus)
|
||||
window.addEventListener('blur', onBlur)
|
||||
@@ -256,6 +253,15 @@ function dispatch (action, ...args) {
|
||||
var mediaTag = document.querySelector('video,audio')
|
||||
if (mediaTag) mediaTag.pause()
|
||||
}
|
||||
if (action === 'escapeBack') {
|
||||
if (state.modal) {
|
||||
dispatch('exitModal')
|
||||
} else if (state.window.isFullScreen) {
|
||||
dispatch('toggleFullScreen')
|
||||
} else {
|
||||
dispatch('back')
|
||||
}
|
||||
}
|
||||
if (action === 'back') {
|
||||
state.location.back()
|
||||
}
|
||||
@@ -1146,18 +1152,6 @@ function onPaste (e) {
|
||||
})
|
||||
}
|
||||
|
||||
function onKeyDown (e) {
|
||||
if (e.which === 27) { /* ESC means either exit fullscreen or go back */
|
||||
if (state.modal) {
|
||||
dispatch('exitModal')
|
||||
} else if (state.window.isFullScreen) {
|
||||
dispatch('toggleFullScreen')
|
||||
} else {
|
||||
dispatch('back')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onFocus (e) {
|
||||
state.window.isFocused = true
|
||||
state.dock.badge = 0
|
||||
|
||||
Reference in New Issue
Block a user