Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useMagicKeys)!: store key instead of keyCode in current #1506

Merged
merged 1 commit into from Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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