JQuery Keydown event not working in Chrome

I am using the following JQuery code to capture keydown events in a DIV:

$("#pnlPreview").keydown(pnlPreview_onKeyDown);

      

The specific keyboard shortcuts I'm trying to capture are as follows:

  • SHIFT + INSERT
  • SHIFT + DELETE
  • CTRL + INSERT
  • CTRL + DELETE

While this code works fine in IE, it doesn't work in Chrome. I am using the latest Chrome browser (38.0.2125.104) under Windows 7.

Can someone please tell me how to capture these keyboard shortcuts in Google Chrome?

See this jsfiddle: jsfiddle.net/fx7do2cf/7. This is the closest duplicate of what I have in my project. Key event events are detected in IE and not detected in Chrome.

+3


source to share


1 answer


The real issue was not that Chrome was not collecting keydown events, but instead it was not possible to set the div in Chrome without the tabIndex attribute on the div. While focus can be set to a div without a tabindex attribute in IE, it cannot be set in Chrome.



All credits for this problem must go to Spokey. He was instrumental in identifying the real problem and solving it.

+3


source







All Articles