mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 03:01:12 +00:00
37 lines
967 B
JavaScript
Vendored
37 lines
967 B
JavaScript
Vendored
export const ctrlPressed = {
|
|
data() {
|
|
return {
|
|
isCtrlCommandPressed: false
|
|
};
|
|
},
|
|
|
|
created() {
|
|
this.handlePointerdown = this.handlePointerdown.bind(this);
|
|
this.handlePointerup = this.handlePointerup.bind(this);
|
|
},
|
|
|
|
mounted() {
|
|
document.addEventListener('pointerdown', this.handlePointerdown);
|
|
document.addEventListener('pointerup', this.handlePointerup);
|
|
},
|
|
|
|
beforeDestroy() {
|
|
document.removeEventListener('pointerdown', this.handlePointerdown);
|
|
document.removeEventListener('pointerup', this.handlePointerup);
|
|
},
|
|
|
|
methods: {
|
|
handlePointerdown(event) {
|
|
if (event.ctrlKey || event.metaKey) {
|
|
this.isCtrlCommandPressed = true;
|
|
}
|
|
},
|
|
|
|
handlePointerup(event) {
|
|
if (!event.ctrlKey && !event.metaKey) {
|
|
this.isCtrlCommandPressed = false;
|
|
}
|
|
}
|
|
}
|
|
};
|