fix: handle backspace navigating back on desktop app

This commit is contained in:
Andrew Bastin
2023-12-18 02:52:59 +05:30
parent 2f773bec79
commit 1b36de4fa3

View File

@@ -96,3 +96,29 @@ const headerPaddingTop = ref("0px")
headerPaddingLeft.value = "70px"
}
})()
function isTextInput(target: EventTarget | null) {
if (target instanceof HTMLInputElement) {
return target.type === 'text'
|| target.type === 'email'
|| target.type === 'password'
|| target.type === 'number'
|| target.type === 'search'
|| target.type === 'tel'
|| target.type === 'url'
|| target.type === 'textarea'
} else if (target instanceof HTMLTextAreaElement) {
return true
} else if (target instanceof HTMLElement && target.isContentEditable) {
return true
}
return false
}
window.addEventListener('keydown',function(e){
if (e.key === "Backspace" && !isTextInput(e.target)) {
e.preventDefault()
}
},true);