mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-08-03 11:07:00 -04:00
(search) open dialogue on mac via ⌘ key instead of ctrl key
This commit is contained in:
parent
8838665a55
commit
6af179c916
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useDebounce } from '@vueuse/core';
|
||||
import { onKeyStroke, useDebounce } from '@vueuse/core';
|
||||
|
||||
const query = ref('');
|
||||
const debouncedQuery = useDebounce(query);
|
||||
@ -37,17 +37,12 @@ const close = () => {
|
||||
dialogue.value?.close();
|
||||
};
|
||||
|
||||
const onKeydown = (event: KeyboardEvent) => {
|
||||
if (event.ctrlKey && event.key === 'k') {
|
||||
onKeyStroke('k', (event) => {
|
||||
const isCtrlKeyPressed = isMac.value ? event.metaKey : event.ctrlKey;
|
||||
if (isCtrlKeyPressed) {
|
||||
event.preventDefault();
|
||||
open();
|
||||
}
|
||||
};
|
||||
onMounted(() => {
|
||||
document.addEventListener('keydown', onKeydown);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('keydown', onKeydown);
|
||||
});
|
||||
|
||||
const onMousedown = (event: MouseEvent) => {
|
||||
|
6
utils/isMac.ts
Normal file
6
utils/isMac.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export default computed(() => {
|
||||
if (!import.meta.client) {
|
||||
return undefined;
|
||||
}
|
||||
return navigator.platform.toLowerCase().includes('mac');
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user