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