Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab7acd9

Browse filesBrowse files
KedlingarSkstud5
andauthored
fix(useMagicKeys): correctly clear current pressed keys when releasing Shift (#4731)
Co-authored-by: Skstud5 <skripchenko@rb.asu.ru>
1 parent 94fea43 commit ab7acd9
Copy full SHA for ab7acd9

File tree

Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-1
lines changed

‎packages/core/useMagicKeys/index.ts

Copy file name to clipboardExpand all lines: packages/core/useMagicKeys/index.ts
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function useMagicKeys(options: UseMagicKeysOptions<boolean> = {}): any {
8585
}
8686
const refs: Record<string, any> = useReactive ? reactive(obj) : obj
8787
const metaDeps = new Set<string>()
88+
const shiftDeps = new Set<string>()
8889
const usedKeys = new Set<string>()
8990

9091
function setRefs(key: string, value: boolean) {
@@ -119,7 +120,16 @@ export function useMagicKeys(options: UseMagicKeysOptions<boolean> = {}): any {
119120
usedKeys.add(key)
120121
setRefs(key, value)
121122
}
122-
123+
if (key === 'shift' && !value) {
124+
shiftDeps.forEach((key) => {
125+
current.delete(key)
126+
setRefs(key, false)
127+
})
128+
shiftDeps.clear()
129+
}
130+
else if (typeof e.getModifierState === 'function' && e.getModifierState('Shift') && value) {
131+
[...current, ...values].forEach(key => shiftDeps.add(key))
132+
}
123133
// #1312
124134
// In macOS, keys won't trigger "keyup" event when Meta key is released
125135
// We track it's combination and release manually

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.