I have in my code a keyup event and I need to catch the @ character. I'm using this code:
$(function() {
  $("#textbox").keyup(function(e) {
    var keynum = e.keyCode;
    if (keynum && e.shiftKey && keynum == 50) {
      // Made a small change.
      console.log("You pressed @ and value is: " + e.target.value);
    }
  })
});<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<input id="textbox" />Now, the problem is that it doesn't work whenever user types shift+2 a little faster
EDIT
You can reproduce this problem by releasing the modifier (shift key) a few milliseconds before the other (2 on my keyboard) key, i.e typing shift + 2 really fast.
@ConstantinGroß was able to address this problem and has a workaround. Please check the accepted answer below.
 
     
    