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.

Can't add separate 'keydown' and 'keyup' actions for the same key

See original GitHub issue

The code below should print both DOWN and UP, but only prints UP.

  hotkeys.bindTo($scope).add({
    combo: 'a', action: 'keydown', callback: function() { 
      console.log("DOWN");
    },
    combo: 'a', action: 'keyup', callback: function() { 
      console.log("UP");
    }
  });

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
ntrpnrcommented, Oct 3, 2016

It actually works if I add the ‘keyup’ action before I add the ‘keydown’ action.

0reactions
devonzaracommented, Oct 27, 2015

That, or just pass the action as a second parameter through to the Mousetrap method as I’ve done here. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keyboard: keydown and keyup - The Modern JavaScript Tutorial
So if we want to track any input into an <input> field, then keyboard events are not enough. There's another event named input...
Read more >
Prevent JavaScript keydown event from being handled ...
In a keyDown function (I have added the document.addEventListener code). Now it works just fine, and does exactly what I want it to...
Read more >
Keydown is the only keyboard event we need - Mutually Human
Keyboard events, keydown and keyup , are independent from each other. In fact, they sandwich the browser performing the action that the user...
Read more >
Element: keydown event - Web APIs | MDN
The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered.
Read more >
Detect single and multiple keypress events: JavaScript
More commonly it is likely that we want to tie the 'do something' to a specific key press. This is why it is...
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