first commit
This commit is contained in:
47
src/stores/command.ts
Normal file
47
src/stores/command.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useCommandPalattesStore = defineStore('command_palettes', () => {
|
||||
const open = ref(false);
|
||||
|
||||
const controlStatus = ref(false)
|
||||
const keyFStatus = ref(false)
|
||||
|
||||
function showCommandPalettes() {
|
||||
open.value = true;
|
||||
}
|
||||
|
||||
function handleOnDismissCommandPalettes() {
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
function onKeyPressed(event: KeyboardEvent) {
|
||||
if (event.key === 'Control') {
|
||||
console.log('control pressed');
|
||||
controlStatus.value = true
|
||||
}
|
||||
|
||||
if (event.key === 'f') {
|
||||
console.log('f pressed');
|
||||
keyFStatus.value = true
|
||||
}
|
||||
|
||||
if (controlStatus.value && keyFStatus.value) {
|
||||
showCommandPalettes()
|
||||
}
|
||||
}
|
||||
|
||||
function onKeyUp(event: KeyboardEvent) {
|
||||
if (event.key === 'Control') {
|
||||
console.log('control released');
|
||||
controlStatus.value = false
|
||||
}
|
||||
|
||||
if (event.key === 'f') {
|
||||
console.log('f released');
|
||||
keyFStatus.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return { open, showCommandPalettes, handleOnDismissCommandPalettes, onKeyPressed, onKeyUp }
|
||||
})
|
Reference in New Issue
Block a user