Skip to content

Commit

Permalink
fix(useMagicKeys)!: store key instead of keyCode in current (#1506
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wvffle committed Jul 6, 2022
1 parent 6f7cd20 commit 5e76f64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core/useMagicKeys/index.ts
Expand Up @@ -51,7 +51,7 @@ export interface MagicKeysInternal {
* A Set of currently pressed keys,
* Stores raw keyCodes.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
*/
current: Set<string>
}
Expand Down Expand Up @@ -100,19 +100,19 @@ export function useMagicKeys(options: UseMagicKeysOptions<boolean> = {}): any {
const values = [code, key].filter(Boolean)

// current set
if (code) {
if (key) {
if (value)
current.add(e.code)
current.add(key)
else
current.delete(e.code)
current.delete(key)
}

for (const key of values)
setRefs(key, value)

// #1312
// In macOS, keys won't trigger "keyup" event when Meta key is released
// We track it's combination and relese manually
// We track it's combination and release manually
if (key === 'meta' && !value) {
// Meta key released
metaDeps.forEach((key) => {
Expand Down

0 comments on commit 5e76f64

Please sign in to comment.