1

I have the following code:

each shortcut is for different functionality, but when I use ctrl+r it displays the alert 4 times. Am I doing anything wrong? the code below looks fine for me...

I'm using chrome, but I don't think it matters

$(document).bind('keydown', 'ctrl+r', function (event) {
    alert("should be only once");
    event.preventDefault();
    return false;
});

$(document).bind('keydown', 'ctrl+1', function () {
    //other code
    return false;
});

$(document).bind('keydown', 'ctrl+2', function () {
    //other code
    return false;
});

$(document).bind('keydown', 'ctrl+3', function () {
    //other code
    return false;
});

Edit: I am using Hotkeys JQuery plugin

ahsteele
  • 26,243
  • 28
  • 134
  • 248
RollRoll
  • 8,133
  • 20
  • 76
  • 135

1 Answers1

0

Make sure the JS isn't being called multiple times. You can unbind(...) it inside the callback function to see if that is what's happening.

Glyph
  • 526
  • 5
  • 20