refactor(core): add stub for addEventListener in useWindow

This commit is contained in:
braks
2023-10-30 13:36:07 +01:00
committed by Braks
parent 4ae371afbb
commit 2a407f59e3
4 changed files with 27 additions and 24 deletions
+3 -5
View File
@@ -72,11 +72,9 @@ export function useKeyPress(keyFilter: MaybeRefOrGetter<KeyFilter | null>, onCha
watch(
() => toValue(keyFilter),
(nextKeyFilter, previousKeyFilter) => {
if (window && typeof window.addEventListener !== 'undefined') {
useEventListener(window, 'blur', () => {
isPressed.value = false
})
}
useEventListener(window, 'blur', () => {
isPressed.value = false
})
// if the previous keyFilter was a boolean but is now something else, we need to reset the isPressed value
if (isBoolean(previousKeyFilter) && !isBoolean(nextKeyFilter)) {