1

Here is a Jsfiddle http://jsfiddle.net/EzLnH/.
If I change the function to:

$(document).bind('keypress', function(event) {
    if (event.which === 77 && event.shiftKey) {
        alert('You pressed ctrl+m');
    }
});​

It works but the function in jsfiddle does not.
Any Ideas?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
xaero
  • 99
  • 1
  • 1
  • 10
  • 1
    Keypress does not work for non-char keys. http://stackoverflow.com/questions/1367700/whats-the-difference-between-keydown-and-keypress-in-net – Eric Nov 15 '12 at 05:59

1 Answers1

1

Chaniging it to $(document).on("keydown"... worked for me. You should be using .on now, .bind is deprecated in jQuery 1.8+. The issue was the "keypress" part though, modifier keys don't get picked up by a keypress event so it seems.

Here's the Fiddle

mash
  • 14,851
  • 3
  • 30
  • 33