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

Remove unnecessary if condition for meta key handling / 去除处理meta key的多余if条件判断 #504

Merged

Conversation

foxhatleo
Copy link
Contributor

@jaywcjlove 不好意思哈好像上一个PR有一个小问题就是如果command按下时按下了别的装饰键,downkeys不会正确重置。有一个if判断里多了一个多余的条件。这个PR修复一下。麻烦您了😅

测试用html:

<!doctype html>
<title>Keyboard shortcut test</title>
<body>
<script type="module">
  const pre = document.createElement('pre')
  document.body.append(pre)
  window.addEventListener('keydown', (e) => {
    const str = [
      e.isComposing ? '(composition)' : false,
      e.ctrlKey ? 'ctrl' : false,
      e.altKey ? 'alt' : false,
      e.metaKey ? 'meta': false,
      e.shiftKey ? 'shift' : false,
      e.key
    ].filter(_ => _).join('+')
    pre.append(str+'\n')
  })

  import hotkey from "./hotkeys.esm.js"
  hotkey('cmd+shift+left', () => pre.append('hotkeys-js cmd+shift+left\n'))
  hotkey('cmd+shift+right', () => pre.append('hotkeys-js cmd+shift+right\n'))
  hotkey('cmd+ctrl+left', () => pre.append('hotkeys-js cmd+shift+left\n'))
  hotkey('cmd+ctrl+right', () => pre.append('hotkeys-js cmd+shift+right\n'))
</script>

@foxhatleo foxhatleo changed the title Remove unnecessary if condition for meta key handling Remove unnecessary if condition for meta key handling / 去除处理meta key的多余if条件判断 Dec 11, 2024
@jaywcjlove jaywcjlove merged commit bcdd3f6 into jaywcjlove:master Dec 12, 2024
1 check passed
jaywcjlove added a commit that referenced this pull request Dec 12, 2024
github-actions bot pushed a commit that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants