1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-25 06:49:23 +01:00

Improves keyboard short cuts and adds a test

This commit is contained in:
Amir Raminfar
2022-09-22 11:13:28 -07:00
parent 59f4b0da4f
commit 7aa7f42c52
4 changed files with 26 additions and 27 deletions

View File

@@ -22,23 +22,17 @@
</template>
<script lang="ts" setup>
const { Meta_F, Ctrl_F, esc } = useMagicKeys({
passive: false,
onEventFired(e) {
if ((e.ctrlKey || e.metaKey) && e.key === "f" && e.type === "keydown") e.preventDefault();
},
});
const input = ref<HTMLInputElement>();
const { searchFilter, showSearch, resetSearch } = useSearchFilter();
whenever(
() => Meta_F.value || Ctrl_F.value,
() => {
onKeyStroke("f", (e) => {
if (e.ctrlKey || e.metaKey) {
showSearch.value = true;
nextTick(() => input.value?.focus() || input.value?.select());
e.preventDefault();
}
);
whenever(esc, () => resetSearch());
});
onUnmounted(() => resetSearch());
</script>