In Chrome, jquery code does not work, but it works in Firefox. What could be the magic?

$(document).keydown(function(e) { if (e.ctrlKey) { alert('work'); }); }); 

OC Ubuntu 12.04

    1 answer 1

    Apparently the event object has no ctrlKey (in Chrome). Try e.keyCode. There you can use the comparison to catch the desired key. At ctrl code 17, judging by the table here

    • Replacing if (e.ctrlKey) with if (e.keyCode == 17) helped! Thanks for the help. - Andrei Stifurak