Bug Tracker

Opened 5 years ago

Closed 5 years ago

#15220 closed bug (wontfix)

In Chrome Browser event.key is undefined in keydown event

Reported by: amalraj Owned by:
Priority: low Milestone: None
Component: event Version: 1.10.2
Keywords: Cc: paul.irish
Blocked by: Blocking:

Description

We are getting event.key as undefined in keydown event. when we use chrome browser. Same code when used on IE,Mozilla works fine. We used Chrome version : 37.0.2062.94 m

Example : http://api.jquery.com/keydown/

Change History (1)

comment:1 Changed 5 years ago by dmethvin

Cc: paul.irish added
Priority: undecidedlow
Resolution: wontfix
Status: newclosed

Yes, there should be a valid key property on that event but Chrome is not creating one, which is why the property is undefined in the jQuery.Event object. http://www.w3.org/TR/DOM-Level-3-Events/#widl-KeyboardEvent-key

To fix it inside jQuery we'd need to have a rather large map and complex logic to create the string, which is just too crazy to contemplate. I'd suggest creating a workaround with keyCode which Chrome does have currently. Someone seems to have created a DOM Level 3 shim if you really need that much generality, but it's really big and doesn't seem to be actively maintained: https://github.com/termi/DOM-Keyboard-Event-Level-3-polyfill

I didn't find a specific Chrome bug for key but did find several about keyCode on Chrome Android. Technically *that* isn't a bug since keyCode is no longer in the spec (you have to go back to a 2010 draft to find it) so the workaround I mentioned above may break at some point. http://www.w3.org/TR/2010/WD-DOM-Level-3-Events-20100907/#events-KeyboardEvent-keyCode https://code.google.com/p/chromium/issues/detail?id=118639

Note: See TracTickets for help on using tickets.