Added CTRL+BACKSPACE and CTRL+V global shortcuts

This commit is contained in:
RemixDev 2020-08-25 15:29:11 +02:00
parent fb87766ea0
commit 1e69e48486
2 changed files with 27 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,10 @@ import { socket } from '@/utils/socket'
import { toast } from '@/utils/toasts' import { toast } from '@/utils/toasts'
import { init as initTabs } from '@js/tabs.js' import { init as initTabs } from '@js/tabs.js'
import { isValidURL } from '@/utils/utils'
import Downloads from '@/utils/downloads'
import EventBus from '@/utils/EventBus.js'
/* ===== App initialization ===== */ /* ===== App initialization ===== */
function startApp() { function startApp() {
@ -39,6 +43,28 @@ function initClient() {
document.addEventListener('DOMContentLoaded', startApp) document.addEventListener('DOMContentLoaded', startApp)
window.addEventListener('pywebviewready', initClient) window.addEventListener('pywebviewready', initClient)
/* ===== Global shortcuts ===== */
document.addEventListener('keyup', keyEvent => {
if (keyEvent.key == "Backspace" && keyEvent.ctrlKey){
let searchbar = document.querySelector('#searchbar')
searchbar.value = ""
searchbar.focus()
}
})
document.addEventListener('paste', pasteEvent => {
pasteText = pasteEvent.clipboardData.getData('Text')
if (pasteEvent.target.localName != "input" && isValidURL(pasteText)){
if (main_selected === 'analyzer_tab') {
EventBus.$emit('linkAnalyzerTab:reset')
socket.emit('analyzeLink', pasteText)
} else {
Downloads.sendAddToQueue(pasteText)
}
}
})
/* ===== Socketio listeners ===== */ /* ===== Socketio listeners ===== */
// Debug messages for socketio // Debug messages for socketio