mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-17 03:31:52 +00:00
Merge pull request #1809 from ZeroX-DG/fix-menu-popup-alt
fixed menu popup on alt key pressed
This commit is contained in:
@@ -24,6 +24,45 @@ document.addEventListener('dragover', function (e) {
|
|||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// prevent menu from popup when alt pressed
|
||||||
|
// but still able to toggle menu when only alt is pressed
|
||||||
|
let isAltPressing = false
|
||||||
|
let isAltWithMouse = false
|
||||||
|
let isAltWithOtherKey = false
|
||||||
|
let isOtherKey = false
|
||||||
|
|
||||||
|
document.addEventListener('keydown', function (e) {
|
||||||
|
if (e.key === 'Alt') {
|
||||||
|
isAltPressing = true
|
||||||
|
if (isOtherKey) {
|
||||||
|
isAltWithOtherKey = true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isAltPressing) {
|
||||||
|
isAltWithOtherKey = true
|
||||||
|
}
|
||||||
|
isOtherKey = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('mousedown', function (e) {
|
||||||
|
if (isAltPressing) {
|
||||||
|
isAltWithMouse = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('keyup', function (e) {
|
||||||
|
if (e.key === 'Alt') {
|
||||||
|
if (isAltWithMouse || isAltWithOtherKey) {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
isAltWithMouse = false
|
||||||
|
isAltWithOtherKey = false
|
||||||
|
isAltPressing = false
|
||||||
|
isOtherKey = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
document.addEventListener('click', function (e) {
|
document.addEventListener('click', function (e) {
|
||||||
const className = e.target.className
|
const className = e.target.className
|
||||||
if (!className && typeof (className) !== 'string') return
|
if (!className && typeof (className) !== 'string') return
|
||||||
|
|||||||
Reference in New Issue
Block a user