mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 11:27:31 -07:00
refactor: ♻️ simplify shift key logic
This commit is contained in:
parent
96e65c74b0
commit
af35eca9f5
1 changed files with 2 additions and 25 deletions
|
@ -31,7 +31,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref } from "vue";
|
||||||
import MkModal from "@/components/MkModal.vue";
|
import MkModal from "@/components/MkModal.vue";
|
||||||
import MkEmojiPicker from "@/components/MkEmojiPicker.vue";
|
import MkEmojiPicker from "@/components/MkEmojiPicker.vue";
|
||||||
import { defaultStore } from "@/store";
|
import { defaultStore } from "@/store";
|
||||||
|
@ -58,22 +58,9 @@ const emit = defineEmits<{
|
||||||
|
|
||||||
const modal = ref<InstanceType<typeof MkModal>>();
|
const modal = ref<InstanceType<typeof MkModal>>();
|
||||||
const picker = ref<InstanceType<typeof MkEmojiPicker>>();
|
const picker = ref<InstanceType<typeof MkEmojiPicker>>();
|
||||||
const isShiftKeyPressed = ref(false);
|
|
||||||
|
|
||||||
const keydownHandler = (e) => {
|
|
||||||
if (e.key === "Shift") {
|
|
||||||
isShiftKeyPressed.value = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const keyupHandler = (e) => {
|
|
||||||
if (e.key === "Shift") {
|
|
||||||
isShiftKeyPressed.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function checkForShift(ev?: MouseEvent) {
|
function checkForShift(ev?: MouseEvent) {
|
||||||
if (!isShiftKeyPressed.value) {
|
if (ev?.shiftKey) {
|
||||||
modal.value?.close(ev);
|
modal.value?.close(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,16 +78,6 @@ function opening() {
|
||||||
}
|
}
|
||||||
picker.value?.focus();
|
picker.value?.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
window.addEventListener("keydown", keydownHandler);
|
|
||||||
window.addEventListener("keyup", keyupHandler);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener("keydown", keydownHandler);
|
|
||||||
window.removeEventListener("keyup", keyupHandler);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in a new issue