Skip to main content

Bug Tracker

Side navigation

#15220 closed bug (wontfix)

Opened August 28, 2014 11:19AM UTC

Closed August 28, 2014 02:26PM UTC

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/

Attachments (0)
Change History (1)

Changed August 28, 2014 02:26PM UTC by dmethvin comment:1

cc: → paul.irish
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