mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
perf: 优化 ctrl 监听
This commit is contained in:
@@ -107,16 +107,17 @@ const macKeyList: Array<string> = [
|
||||
|
||||
// 处理键盘记录
|
||||
const keyRecordHandle = () => {
|
||||
// 初始化清空
|
||||
if(window.$KeyboardActive) window.$KeyboardActive = new Set([])
|
||||
|
||||
// 默认赋值
|
||||
window.$KeyboardActive = {
|
||||
ctrl: true
|
||||
}
|
||||
|
||||
document.onkeydown = (e: KeyboardEvent) => {
|
||||
if(window.$KeyboardActive) window.$KeyboardActive.add(e.key.toLocaleLowerCase())
|
||||
else window.$KeyboardActive = new Set([e.key.toLocaleLowerCase()])
|
||||
if(e.keyCode === 17 && window.$KeyboardActive) window.$KeyboardActive.ctrl = true
|
||||
}
|
||||
|
||||
document.onkeyup = (e: KeyboardEvent) => {
|
||||
if(window.$KeyboardActive) window.$KeyboardActive.delete(e.key.toLocaleLowerCase())
|
||||
if(e.keyCode === 17 && window.$KeyboardActive) window.$KeyboardActive.ctrl = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user