question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matching non-modified key also picks up the same modified key

See original GitHub issue

For example if I’m looking for 'shift+left' and 'left', looking for 'left' will also pick up 'shift+left'.

Here is a test case that will fail illustrating the problem:

it('matches only modified hotkey a', () => {
  const check = isHotkey(['shift+a'])
  const a = check(e(65, 'shift'))
  const shifta = check(e(65, 'shift'))
  assert.equal(a, false)
  assert.equal(shifta, true)
})

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ianstormtaylorcommented, Oct 24, 2018

Fixed in 0.1.4, thank you both!

1reaction
ericedemcommented, Oct 24, 2018

Ugh sorry for all the churn, after stepping through a few times on both sides, it looks like byKey is getting used implicitly by isKeyHotkey which is what slate is using. Here is an actual test case that fails with the shift null check you initially suggested:

it('matches only modified hotkey left', () => {
  // equivalent to isKeyHotkey('left', e('left', 'shift'))
  const shiftleft = isHotkey('left', { byKey: true }, e('left', 'shift')) 
  assert.equal(shiftleft, true)
})

The problem is that because shiftKey is getting set to null it is just ignored when checking equality of the event: https://github.com/ianstormtaylor/is-hotkey/blob/master/src/index.js#L171

It looks like setting shift to null should only happen onKeyUp? Or maybe the check should just be removed all together?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifier Keys - the Tcler's Wiki!
The "Windows" Modifier key takes the role of the Command/Apple/⌘ key. The Left-Alt and Right-Alt keys perform the same role, as on a...
Read more >
Authorize with Shared Key (REST API) - Azure Storage
Learn how to authorize a request to Azure Storage with Shared Key.
Read more >
How Match Keys Are Generated and Used in Matching Rules
Match keys help to increase the performance of duplicate rules through a preliminary comparison that narrows the matches to the 100 most likely...
Read more >
CopyObject - Amazon Simple Storage Service
Creates a copy of an object that is already stored in Amazon S3. ... You can store individual objects of up to 5...
Read more >
A Deep Dive on End-to-End Encryption: How Do Public ...
If you encode a message using a person's public key, they can decode it using their matching private key. Julia and César are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found