0

I have to get combination of key press on a page. I wrote a code

$(document).keydown(function (e) {
    if (e.which == 16 && e.which == 48) {
        alert('hi');
    }
}

but is not working. How can I get the combination of two or more keys?

Anton
  • 32,245
  • 5
  • 44
  • 54
Divya
  • 979
  • 3
  • 13
  • 18

1 Answers1

0

You can use e.shiftKey

$(document).keydown(function (e) {
    if (e.keyCode == 48 && e.shiftKey) {        
        alert('hi');
    }
});

DEMO

Anton
  • 32,245
  • 5
  • 44
  • 54